javascript - Issue with vertical line (Google chart) -


folks,

i trying create column chart using google chart api , having lots of issue in getting y-axis line.

i understand x-axis string why vertical grid line not coming y-axis line must come. marking in red of line not coming.

enter image description here

i have following code.

function drawchartsecond(resp) {     var data = new google.visualization.datatable();     data.addcolumn('string', 'activity');     data.addcolumn('number', 'hours');      data.addrows([         ['work', 11],         ['eat', 2 ],         ['commute', 2 ],         ['watch tv', 2],         ['sleep', 7]     ]);     var options = {         title : '',         legend: {             position: 'right',             alignment: 'center'         },         tooltip: {             ishtml: true         },         haxis: {             title: 'activity',             titletextstyle: {                 color: 'black',                 fontsize : '12',                 fontname : 'arial'             },             baselinecolor: '#cccccc'         },         chartarea : {             left: '8%',             top: '8%',             height:'70%',             width:'100%'         }     };     var chart = new google.visualization.columnchart(document.getelementbyid('chartdivsecond'));     chart.draw(data, options); } 

the way baseline use chart continuous axis. can use dataview convert data appropriately formatted numbers, , use haxis.ticks option re-label axis tick marks looks correct:

function drawchartsecond(resp) {     var data = new google.visualization.datatable();     data.addcolumn('string', 'activity');     data.addcolumn('number', 'hours');     data.addrows([         ['work', 11],         ['eat', 2 ],         ['commute', 2 ],         ['watch tv', 2],         ['sleep', 7]     ]);      var view = new google.visualization.dataview(data);     view.setcolumns([{         type: 'number',         label: data.getcolumnlabel(0),         calc: function (dt, row) {             return {v: row + 1, f: dt.getvalue(row, 0)};         }     }, 1]);      var ticks = [];     (var = 0; < data.getnumberofrows(); i++) {         ticks.push({v: + 1, f: data.getvalue(i, 0)});     }      var options = {         title : '',         legend: {             position: 'right',             alignment: 'center'         },         tooltip: {             ishtml: true         },         haxis: {             title: 'activity',             titletextstyle: {                 color: 'black',                 fontsize : '12',                 fontname : 'arial'             },             baselinecolor: '#cccccc',             ticks: ticks         },         chartarea : {             left: '8%',             top: '8%',             height:'70%',             width:'100%'         }     };     var chart = new google.visualization.columnchart(document.getelementbyid('chartdivsecond'));     chart.draw(view, options); } 

see working example: http://jsfiddle.net/asgallant/6mxkv/


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -