Auto width scroll bar in Google Chart

后端 未结 1 1095
走了就别回头了
走了就别回头了 2020-12-17 06:34

I using the Google Chart for in my HTML5 Project. which takes the JSON values ( from DB ) to plot the graph.

my need is to have a scroll bar if the datas are more th

相关标签:
1条回答
  • 2020-12-17 06:56

    Here's the solution: http://jsfiddle.net/hsakX/

    Set the bar.groupWidth option to fix the width of the bars. Then make the width of the chart a function of the bar-width and the number of bars to be displayed:

    var options = {            
        title: 'Company Performance',
        hAxis: {title: 'Year', titleTextStyle: {color: 'red'}},
        width: data.getNumberOfRows() * 65,
        bar: {groupWidth: 20}
    };
    

    Set the overflow-x on the containing div to scroll:

    #chart_div {
     overflow-x: scroll;
     overflow-y: hidden;     
     width: 500px;
     height: 550px;
    }
    
    0 讨论(0)
提交回复
热议问题