1

usage - Angular NVD3 LineChart

I am getting data, but when data is 0, it plots the graph and plot y axis from range -1,0,1.

But i do want to plot in negative y axis, since my data can never be negative.

X-axis contains time.

My graph progresses as the time elapsed increases, issue is like for first few minutes data will be 0, then afterwards i will start getting data.

JavaScript Code

$scope.options = {
                        chart: {
                            type: 'lineChart',
                            height: 120,
                            margin : {
                                top: 8,
                                bottom: 30,
                                left:40,
                                right:50,
                            },
                      color: ['#e4a91d','#444fa2','#de0000']
                    , showLegend: false
                    , wrapLabels: true
                    , tooltips:true
                    , reduceXTicks: false,


                            x: function(d){ return d[0]; },
                            y: function(d){ return d[1]; },

                            showDistY: true,
                            showDistX: true,
                            useInteractiveGuideline: true,
                            transitionDuration: 10,

                            xAxis: {
                                axisLabel: '',
                                tickFormat: function(d) {
                                    return d3.time.format('%H:%M')(new Date(d));
                                },
                                tickPadding: 10,
                                axisLabelDistance: 1,
                                ticks: 10,
                            },

                            yAxis: {
                                axisLabel: '1 / 2 / 3',
                                tickFormat: function(d){
                                    return d;
                                },
                                ticks: 4,
                            }
                        }
                    };

Html Code

<div>
    <nvd3 options="options" data="data" api="api"></nvd3>
</div>

Screenshot

enter image description here

4

1 回答 1

5

我认为这应该有效。将这些添加到您的图表对象 中,我在图表中使用了类似的东西。在这里找到它https://github.com/krispo/angular-nvd3/issues/47 yDomain: [0, maxY] // maxY being whatever you want your max y value to be

于 2016-03-09T16:17:50.367 回答