Skip to content

Commit

Permalink
fix($browser): Use dynamic step value for margin instead of fixed value.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: None.
  • Loading branch information
t-mullen committed Jan 17, 2019
1 parent 9f54468 commit b9910f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/base-axis-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class BaseAxisChart extends BaseChart {
const chartSize = this.getChartSize();
const width = chartSize.width - margins.left - margins.right;

this.x = scaleBand().rangeRound([0, width]).padding(Configuration.scales.x.padding);
this.x = scaleBand().rangeRound([0, width]);
this.x.domain(this.displayData.labels);
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/line-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class LineChart extends BaseAxisChart {

// D3 line generator function
this.lineGenerator = line()
.x((d, i) => this.x(this.displayData.labels[i]) + margins.left)
.x((d, i) => this.x(this.displayData.labels[i]) + this.x.step() / 2)
.y((d: any) => this.y(d))
.curve(getD3Curve(curveName, curveOptions));

Expand All @@ -86,7 +86,7 @@ export class LineChart extends BaseAxisChart {
.enter()
.append("circle")
.attr("class", "dot")
.attr("cx", d => this.x(d.label) + margins.left)
.attr("cx", d => this.x(d.label) + this.x.step() / 2)
.attr("cy", d => this.y(d.value))
.attr("r", Configuration.charts.pointCircles.radius)
.attr("stroke", d => this.colorScale[d.datasetLabel](d.label));
Expand Down Expand Up @@ -130,7 +130,7 @@ export class LineChart extends BaseAxisChart {
.enter()
.append("circle")
.attr("class", "dot")
.attr("cx", (d, i) => this.x(d.label) + margins.left)
.attr("cx", (d, i) => this.x(d.label) + this.x.step() / 2)
.attr("cy", (d: any) => this.y(d.value))
.attr("r", 4)
.style("opacity", 0)
Expand Down Expand Up @@ -189,7 +189,7 @@ export class LineChart extends BaseAxisChart {
return self.addLabelsToDataPoints(parentDatum, i);
})
.transition(transitionToUse)
.attr("cx", d => this.x(d.label) + margins.left)
.attr("cx", d => this.x(d.label) + this.x.step() / 2)
.attr("cy", d => this.y(d.value))
.attr("r", Configuration.lines.points.strokeWidth)
.attr("stroke", d => this.colorScale[d.datasetLabel](d.label));
Expand Down

0 comments on commit b9910f0

Please sign in to comment.