nvd3 date comparison on x axis

100 views Asked by At

As you can see on the photo, I pushed 2 different series to the nvd3 with datum function. Current line shows today and previous line shows previous range of date of data. What If I want to merge it on single range with first array of series, which means current. What sould I do on nvd3?

nv.addGraph(() => {
            var height = 400;
            var chart = nv.models.lineChart().useInteractiveGuideline(true).showLegend(true).showYAxis(true).showXAxis(true);
            //chart.xAxis.axisLabel('Date').tickValues((d) => d3.time.format("%Y-%m-%d")(new Date(d)));
            chart.yAxis.axisLabel('Voltage (v)').tickFormat(d3.format('.02f'));
            this.redraw(chart)
            this.chartRef = chart
        });
        d3.select(this.$refs.chart).datum(this.metrics.series).call(chart);

You can find the example of series below:

{"series":[{"key":"Current","values":[{"x":1609680551000,"y":"0.00"},{"x":1609766951000,"y":"0.00"},{"x":1609853351000,"y":"0.00"},{"x":1609939751000,"y":"0.00"},{"x":1610026151000,"y":"0.00"},{"x":1610112551000,"y":"0.00"},{"x":1610198951000,"y":"0.00"},{"x":1610285351000,"y":"0.00"}]},{"key":"Previous","values":[{"x":1609075751000,"y":"0.00"},{"x":1609162151000,"y":"0.00"},{"x":1609248551000,"y":"0.00"},{"x":1609334951000,"y":"0.00"},{"x":1609421351000,"y":"0.00"},{"x":1609507751000,"y":"0.00"},{"x":1609594151000,"y":"0.00"},{"x":1609680551000,"y":"0.00"}]}]}

nvd3 date

0

There are 0 answers