最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Changing x axis ticks in Material google bar charts - Stack Overflow

matteradmin5PV0评论

I am trying to build a usage bar chart using . I was wondering how can I maximize the range of the X-axis tick marks? I've tried doing that in the fiddle / using the suggestion from another post - set x Axis range in google chart but that did not work. This is what I added to the existing fiddle:

hAxis: {
        viewWindow: {
              max: 200
        },
        ticks: [0,50,100]
}

but that does not seem work. Any help would be much appreciated!

I am trying to build a usage bar chart using https://developers.google./chart/interactive/docs/gallery/barchart#top-x. I was wondering how can I maximize the range of the X-axis tick marks? I've tried doing that in the fiddle https://jsfiddle/gbta075L/ using the suggestion from another post - set x Axis range in google chart but that did not work. This is what I added to the existing fiddle:

hAxis: {
        viewWindow: {
              max: 200
        },
        ticks: [0,50,100]
}

but that does not seem work. Any help would be much appreciated!

Share Improve this question edited Dec 15, 2017 at 3:02 Jeremy Logan 47.5k39 gold badges125 silver badges145 bronze badges asked May 18, 2015 at 23:19 bazzingabazzinga 1751 gold badge5 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

I honestly dont know how to construct the ticks and viewWindow equivalences when using googles material bar charts. It is not so well documented and still in beta.

However, a nice trick is to use google.charts.Bar.convertOptions() which translates google visualization options into material chart options :

var chart = new google.charts.Bar(document.getElementById('top_x_div'));
chart.draw(data, google.charts.Bar.convertOptions(options));

results in this

Which I assume is what you want.
forked fiddle -> https://jsfiddle/65bwmknu/

Post a comment

comment list (0)

  1. No comments so far