javascript - Google Visualisation - column chart interval issue (duplicate intervals) -


enter image description here

i'm using following code generate above google chart:

var data = google.visualization.arraytodatatable([ ['date', 'tickets'], ['11/05/15',1], ['10/05/15',0], ['09/05/15',0], ['08/05/15',0], ['07/05/15',0], ['06/05/15',0], ['05/05/15',0], ['04/05/15',0], ]);  var columnchartoptions = { title: "", legend: { position: 'none' }, width: '100%', height: '100%', colors: ["#27ae60", "#2980b9", "#e67e22", "#e74c3c", "#e74c3c"], chartarea: { left: '8%', top: '8%', width: "85%", height: "70%" },  vaxis: { minvalue: 1, format:'#' },  new google.visualization.columnchart(document.getelementbyid('ticket-history-graph')). draw(data,columnchartoptions); 

however produces following wrong interval counts:

what changes need make vaxis definition correct this? i've tried varying min , max values no avail. must add when higher numbers used not problem, it's lower counts.

your problem format:'#', reason why 2 zeros , 3 ones (as round 0 decimals, , graph tries present values [0, 0.25, 0.5, 0.75, 1] rounded [0, 0, 1, 1, 1], therefore duplicates them).

my suggestion check out property vaxis.gridlines.count documentation.

i made fiddle, check if maxvalue in graph 1 or 2, if specify gridlines either count of 2 or 3, , if it's neither 1 or 2, uses googles own automatic generation. check , see if follow how i've done: jsfiddle
remember try , change values higher/lower see how works.

//get distinct ticketsales, sorted ascending default, have last value highest one.     var maxvalue = data.getdistinctvalues(1)[data.getdistinctvalues(1).length - 1]      // specify gridcount null, if doesn't enter of if's below, still null     var gridcount = null      //check if highest value 1 or 2 else leave gridcount null     if (maxvalue == 1) {         gridcount = 2     }     if (maxvalue == 2) {         gridcount = 3     } 

aswell addition columnchartoptions:

 vaxis: {             gridlines: {                 //specify amount of gridlines var gridcount, if it's still specified null, use googles automatic generation.                 count: gridcount             }, 

Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -