小编rio*_*ted的帖子

NVD3.js折线图无法将y轴缩放为最大值和最小值

建立一个包含多个图形的页面,我决定使用NVD3.

问题是NVD3无法找到最大值,导致一些无用的图形.

http://jsfiddle.net/pxU8c/

function renderGraph(parent, data) {
    function getGraph(svgElement, data) {
        var height = 500;

        var chart = nv.models.lineChart()
        chart.options({
            noData: "Not enough data to graph",
            transitionDuration: 500,
            showLegend: true,
            showXAxis: true,
            showYAxis: true,
            rightAlignYAxis: false
        });

        chart.xAxis     //Chart x-axis settings
            .axisLabel(data['x-label'])
            .tickFormat(function(d) {
                return d3.time.format('%d.%m.%Y')(new Date(+d))
            });

        chart.yAxis     //Chart y-axis settings
            .axisLabel(data['y-label'])
            .tickFormat(d3.format('.02f'))
        ;

        svgElement    //Select the <svg> element you want to render the chart in.
            .datum(data['data'])         //Populate the <svg> element with chart data...
            .call(chart);          //Finally, render the chart! …
Run Code Online (Sandbox Code Playgroud)

javascript html5 d3.js twitter-bootstrap nvd3.js

2
推荐指数
1
解决办法
1498
查看次数

标签 统计

d3.js ×1

html5 ×1

javascript ×1

nvd3.js ×1

twitter-bootstrap ×1