可滚动的canvasjs图表

时间:2017-06-13 13:48:44

标签: javascript charts canvasjs

我试图制作可滚动的垂直canvasjs图表。

这是html:

<div style="height:300px; width: 100%; overflow-y:scroll">
    <div id="dataContainer" style="width: 100%;"></div>
</div>

这是javascript:

var chart = new CanvasJS.Chart("dataContainer",
{  
    title:{
        text: data['name']            
    },
    axisY:{
       gridThickness: 0,
     },           
    data: [{
        animationEnabled: false,
        indexLabelPlacement: "inside",
        indexLabelFontColor: "white",
        indexLabelFontWeight: 600,
        indexLabelFontFamily: "Verdana",
        type: "bar",
        dataPoints: dataPoints[0]
    },
    {
        animationEnabled: false,
        indexLabelPlacement: "inside",
        indexLabelFontColor: "white",
        indexLabelFontWeight: 600,
        indexLabelFontFamily: "Verdana",
        type: "bar",
        dataPoints: dataPoints[1]
    }           
    ]
});

chart.render(); 

结果如下:

enter image description here

我添加了dataPointWidth:

var chart = new CanvasJS.Chart("dataContainer",
{  
    dataPointWidth: 20, 
    title:{
        text: data['name']            
    },
 ...
};

这是结果(看起来像一个bug):

enter image description here

如何使用滚动条和正常大小的列制作图表?

1 个答案:

答案 0 :(得分:-1)

google charts library运行正常。