Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(bug): fix vertical offset line chart issue #32

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/charts/line-chart/axes.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ export function yAxisMinMax({
let x = -1 * (leftMargin - leftOffset);
let y = scale(d.value) + axisFontSize * 0.4;

// Adjust the first datapoint to match with the vertical baseline of the chart.
if (d.value === firstEventYValue) {
y -= (defaultDataset.verticalBaselineOffset || 0);
}
// Adjust datapoints upward to take into account vertical offset defined on default dataset
y -= (defaultDataset.verticalBaselineOffset || 0);

return `translate(${x},${y})`;
});
mergeSelection.select('.axis-y-point-label')
Expand Down Expand Up @@ -161,7 +160,7 @@ export function yAxisMinMax({
.attr('x', leftMargin - leftOffset)
.attr('y', -1 * (axisFontSize * 0.4))
.attr('width', graphWidth)
.attr('height', d => scale(0) - scale(d.value))
.attr('height', d => (scale(0) - scale(d.value)) + (defaultDataset.verticalBaselineOffset || 0))
.attr('fill', d => {
if (d.hasShadow) {
return 'rgba(65, 152, 255, 0.1)';
Expand Down