score:0

problem solved.

To render the barchart and linechart I have two different functions. In each function I have called the x.domain.

In LineChart only:

x.domain([d3.min(data, function (d) { return d.xValue; }), d3.max(data, function (d) { return d.xValue; })]);

But in BarChart:

var xMax = d3.max(data, function (d) { return d.xValue; });
        xMax = new Date(xMax.toString()); // otherwise data[<last>].xValue is changed as well!
        if (ChartHandler.SelectedAggregationPeriod == ChartHandler.AggregationPeriod.month) {
            xMax.setTime(xMax.getTime() + 12 * 60 * 60 * 1000); //+12h
        }
 var xMin = d3.min(data, function (d) { return d.xValue; });

        x.domain([xMin, xMax]);

that's it.... ©a-x-i


Related Query

More Query from same tag