diff --git a/src/components/Graphs/MultiLineGraph/index.js b/src/components/Graphs/MultiLineGraph/index.js index 505530cb..4c9c18c6 100644 --- a/src/components/Graphs/MultiLineGraph/index.js +++ b/src/components/Graphs/MultiLineGraph/index.js @@ -1,6 +1,5 @@ import React from "react"; import XYGraph from "../XYGraph"; -import { Actions } from "../../App/redux/actions"; import { connect } from "react-redux"; import { @@ -14,7 +13,6 @@ import { select, brushX, voronoi, - merge, event } from "d3"; @@ -42,7 +40,6 @@ class LineGraph extends XYGraph { chartHeightToPixel, chartWidthToPixel, circleToPixel, - colorColumn, colors, legend, linesColumn, @@ -79,8 +76,8 @@ class LineGraph extends XYGraph { }); let filterDatas = []; - data.map((d) => { - legendsData.map((ld) => { + data.forEach((d) => { + legendsData.forEach((ld) => { filterDatas.push(Object.assign({ yColumn: d[ld['key']], columnType: ld['key'] @@ -89,10 +86,14 @@ class LineGraph extends XYGraph { }); const isVerticalLegend = legend.orientation === 'vertical'; - const xLabelFn = (d) => d[xColumn]; + + const xLabelFn = (d) => d[xColumn]; + + const yLabelUnformattedFn = (d) => d['yColumn']; + const yLabelFn = (d) => { if(!yTickFormat) { - return d; + return d['yColumn']; } const formatter = format(yTickFormat); return formatter(d['yColumn']); @@ -103,19 +104,15 @@ class LineGraph extends XYGraph { const scale = this.scaleColor(legendsData, 'key'); const getColor = (d) => scale ? scale(d['key']) : stroke.color || colors[0]; - let xAxisHeight = xLabel ? chartHeightToPixel : 0; let legendWidth = legend.show && legendsData.length >= 1 ? this.longestLabelLength(legendsData, legendFn) * chartWidthToPixel : 0; - let xLabelWidth = this.longestLabelLength(data, xLabelFn) * chartWidthToPixel; let yLabelWidth = this.longestLabelLength(filterDatas, yLabelFn) * chartWidthToPixel; let leftMargin = margin.left + yLabelWidth; let availableWidth = width - (margin.left + margin.right + yLabelWidth); let availableHeight = height - (margin.top + margin.bottom + chartHeightToPixel + xAxisHeight); - - if (legend.show) { legend.width = legendWidth; @@ -136,7 +133,8 @@ class LineGraph extends XYGraph { const xScale = scaleTime() .domain(extent(data, xLabelFn)); const yScale = scaleLinear() - .domain(extent(filterDatas, yLabelFn)); + .domain(extent(filterDatas, yLabelUnformattedFn)); + xScale.range([0, availableWidth]); yScale.range([availableHeight, 0]);