Adds y axis

This commit is contained in:
Roman Galochkin 2020-02-20 12:31:10 +03:00
parent f784c2fcb2
commit 00589ad310

View File

@ -221,6 +221,8 @@ export class CdfChartD3 {
}); });
} }
this.yAxis = d3.axisRight(this.yScale);
// Objects. // Objects.
const line = d3.line() const line = d3.line()
.x(d => this.xScale(d.x)) .x(d => this.xScale(d.x))
@ -236,6 +238,9 @@ export class CdfChartD3 {
.attr('transform', 'translate(0,' + this.calc.chartHeight + ')') .attr('transform', 'translate(0,' + this.calc.chartHeight + ')')
.call(this.xAxis); .call(this.xAxis);
this.chart.createObject({ tag: 'g', selector: 'y-axis' })
.call(this.yAxis);
// Draw area. // Draw area.
this.chart this.chart
.createObjectsWithData({ .createObjectsWithData({
@ -320,7 +325,7 @@ export class CdfChartD3 {
.attr("transform", "translate(0," + this.calc.chartHeight + ")") .attr("transform", "translate(0," + this.calc.chartHeight + ")")
.call(d3.axisBottom(x)); .call(d3.axisBottom(x));
// Add Y axis // Y axis
const y = d3.scaleLinear() const y = d3.scaleLinear()
.domain([0, 50]) .domain([0, 50])
.range([this.calc.chartHeight, 0]); .range([this.calc.chartHeight, 0]);