Skip to content
Merged
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
22 changes: 10 additions & 12 deletions src/components/Graphs/MultiLineGraph/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from "react";
import XYGraph from "../XYGraph";
import { Actions } from "../../App/redux/actions";
import { connect } from "react-redux";

import {
Expand All @@ -14,7 +13,6 @@ import {
select,
brushX,
voronoi,
merge,
event
} from "d3";

Expand Down Expand Up @@ -42,7 +40,6 @@ class LineGraph extends XYGraph {
chartHeightToPixel,
chartWidthToPixel,
circleToPixel,
colorColumn,
colors,
legend,
linesColumn,
Expand Down Expand Up @@ -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']
Expand All @@ -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']);
Expand All @@ -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;
Expand All @@ -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]);
Expand Down