Skip to content

Commit

Permalink
Merge pull request #380 from nuagenetworks/feature/vnf
Browse files Browse the repository at this point in the history
Feature/vnf
  • Loading branch information
ronakmshah authored Jun 5, 2017
2 parents 02e9bde + bada6e7 commit 1bc491e
Showing 1 changed file with 10 additions and 12 deletions.
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

0 comments on commit 1bc491e

Please sign in to comment.