GeoChart: markers load very slowly - google-visualization
google.charts.load('current', {'packages':['geochart']});
google.charts.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var query = new google['visualization'].Query('https://docs.google.com/spreadsheets/d/____&headers=1&range=A1:B')
query.send(handleQueryResponseTR);
}
function handleQueryResponseTR(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var options = {
region: 'world',
displayMode: 'markers',
sizeAxis: { minValue: 0, maxValue: 5 },
colorAxis: {
colors: ['#fff', '#000']
},
legend: 'none'
};
var data = response.getDataTable();
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(data, options);
};
The spreadsheet has the format:
Country Value
XX XX
XX XX
There are approximately 40 entries (40 different countries).
Everything works, but the map loads the markers one by one and it takes about 30 seconds to load all of them. Why is it so slow? It's not the fact that it's loading them from a Google Sheets, even when hard coded the load time is the same.
JSFIDDLE
when in markers mode format, using latitude and longitude seems to work best...
loads instantly...
use a data view to add the country name to the tooltip,
see following working snippet...
google.charts.load('current', {
callback: drawRegionsMap,
packages: ['geochart']
});
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Lat','Lng','Value','Country'],
[41.153332,20.168331,58,'Albania'],
[-25.274398,133.775136,28,'Australia'],
[40.143105,47.576927,47,'Azerbaijan'],
[23.684994,90.356331,52,'Bangladesh'],
[-3.373056,29.918886,76,'Burundi'],
[12.565679,104.990963,28,'Cambodia'],
[56.130366,-106.346771,79,'Canada'],
[-35.675147,-71.542969,48,'Chile'],
[26.820553,30.802498,7,'Egypt'],
[-16.578193,179.414413,127,'Fiji'],
[46.227638,2.213749,25,'France'],
[51.165691,10.451526,29,'Germany'],
[22.396428,114.109497,9,'Hong Kong'],
[20.593684,78.96288,119,'India'],
[-0.789275,113.921327,35,'Indonesia'],
[31.046051,34.851612,41,'Israel'],
[41.87194,12.56738,4,'Italy'],
[30.585164,36.238414,102,'Jordan'],
[-0.023559,37.906193,121,'Kenya'],
[29.31166,47.481766,59,'Kuwait'],
[33.854721,35.862285,127,'Lebanon'],
[55.169438,23.881275,3,'Lithuania'],
[23.634501,-102.552784,10,'Mexico'],
[9.081999,8.675277,48,'Nigeria'],
[30.375321,69.345116,91,'Pakistan'],
[31.952162,35.233154,66,'Palestinian Territories'],
[12.879721,121.774017,80,'Philippines'],
[51.919438,19.145136,242,'Poland'],
[25.354826,51.183884,86,'Qatar'],
[45.943161,24.96676,35,'Romania'],
[61.52401,105.318756,133,'Russia'],
[23.885942,45.079162,15,'Saudi Arabia'],
[1.352083,103.819836,2,'Singapore'],
[48.669026,19.699024,9,'Slovakia'],
[35.907757,127.766922,41,'South Korea'],
[40.463667,-3.74922,111,'Spain'],
[7.873054,80.771797,97,'Sri Lanka'],
[-6.369028,34.888822,34,'Tanzania'],
[13.443182,-15.310139,129,'Gambia'],
[38.963745,35.243322,2,'Turkey'],
[23.424076,53.847818,85,'United Arab Emirates'],
[55.378051,-3.435973,56,'United Kingdom'],
[48.379433,31.16558,97,'Ukraine'],
[37.09024,-95.712891,130,'United States'],
[6.42375,-66.58973,120,'Venezuela'],
[45.1,15.2,20,'Croatia']
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, 2, {
calc: function (dt, row) {
return dt.getValue(row, 3) + ': ' + dt.getFormattedValue(row, 2);
},
role: 'tooltip',
type: 'string'
}]);
var options = {
displayMode: 'markers',
};
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(view, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="geochart-colors"></div>
note: found country lat / lng list here -->
countries.csv
see following snippet for comparing load time with country name only...
google.charts.load('current', {
callback: drawRegionsMap,
packages: ['geochart']
});
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Country', 'Value'],
[{v: 'Albania'}, {v: 58}],
[{v: 'Australia'}, {v: 28}],
[{v: 'Azerbaijan'}, {v: 47}],
[{v: 'Bangladesh'}, {v: 52}],
[{v: 'Burundi'}, {v: 76}],
[{v: 'Cambodia'}, {v: 28}],
[{v: 'Canada'}, {v: 79}],
[{v: 'Chile'}, {v: 48}],
[{v: 'Egypt'}, {v: 7}],
[{v: 'Fiji'}, {v: 127}],
[{v: 'France'}, {v: 25}],
[{v: 'Germany'}, {v: 29}],
[{v: 'Hong Kong'}, {v: 9}],
[{v: 'India'}, {v: 119}],
[{v: 'Indonesia'}, {v: 35}],
[{v: 'Israel'}, {v: 41}],
[{v: 'Italy'}, {v: 4}],
[{v: 'Jordan'}, {v: 102}],
[{v: 'Kenya'}, {v: 121}],
[{v: 'Kuwait'}, {v: 59}],
[{v: 'Lebanon'}, {v: 127}],
[{v: 'Lithuania'}, {v: 3}],
[{v: 'Mexico'}, {v: 10}],
[{v: 'Nigeria'}, {v: 48}],
[{v: 'Pakistan'}, {v: 91}],
[{v: 'Pakistan Balochistan'}, {v: 55}],
[{v: 'Palestine, State of'}, {v: 66}],
[{v: 'Philippines'}, {v: 80}],
[{v: 'Poland'}, {v: 242}],
[{v: 'Qatar'}, {v: 86}],
[{v: 'Romania'}, {v: 35}],
[{v: 'Russian Federation'}, {v: 133}],
[{v: 'Saudi Arabia'}, {v: 15}],
[{v: 'Singapore'}, {v: 2}],
[{v: 'Slovakia'}, {v: 9}],
[{v: 'Korea, Republic of'}, {v: 41}],
[{v: 'Spain'}, {v: 111}],
[{v: 'Sri Lanka'}, {v: 97}],
[{v: 'Tanzania, United Republic of'}, {v: 34}],
[{v: 'Gambia'}, {v: 129}],
[{v: 'Turkey'}, {v: 2}],
[{v: 'United Arab Emirates'}, {v: 85}],
[{v: 'United Kingdom'}, {v: 56}],
[{v: 'Ukraine'}, {v: 97}],
[{v: 'United States'}, {v: 130}],
[{v: 'Venezuela, Bolivarian Republic of'}, {v: 120}],
[{v: 'Croatia'}, {v: 20}]
]);
var options = {
displayMode: 'markers',
};
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(data, options);
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="geochart-colors"></div>
EDIT
remove the coordinates from the tooltip by using option --> tooltip.isHtml: true
tooltip: {
isHtml: true
}
and the following css...
.google-visualization-tooltip-item:first-child {
display: none;
visibility: hidden;
}
the tooltip column must have a property for --> p: {html: true}
and for some reason, column properties are not recognized
when using a data view to draw the chart
to correct, convert the view to a data table before drawing...
view.toDataTable()
see following working snippet...
google.charts.load('current', {
callback: drawRegionsMap,
packages: ['geochart']
});
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Lat','Lng','Value','Country'],
[41.153332,20.168331,58,'Albania'],
[-25.274398,133.775136,28,'Australia'],
[40.143105,47.576927,47,'Azerbaijan'],
[23.684994,90.356331,52,'Bangladesh'],
[-3.373056,29.918886,76,'Burundi'],
[12.565679,104.990963,28,'Cambodia'],
[56.130366,-106.346771,79,'Canada'],
[-35.675147,-71.542969,48,'Chile'],
[26.820553,30.802498,7,'Egypt'],
[-16.578193,179.414413,127,'Fiji'],
[46.227638,2.213749,25,'France'],
[51.165691,10.451526,29,'Germany'],
[22.396428,114.109497,9,'Hong Kong'],
[20.593684,78.96288,119,'India'],
[-0.789275,113.921327,35,'Indonesia'],
[31.046051,34.851612,41,'Israel'],
[41.87194,12.56738,4,'Italy'],
[30.585164,36.238414,102,'Jordan'],
[-0.023559,37.906193,121,'Kenya'],
[29.31166,47.481766,59,'Kuwait'],
[33.854721,35.862285,127,'Lebanon'],
[55.169438,23.881275,3,'Lithuania'],
[23.634501,-102.552784,10,'Mexico'],
[9.081999,8.675277,48,'Nigeria'],
[30.375321,69.345116,91,'Pakistan'],
[31.952162,35.233154,66,'Palestinian Territories'],
[12.879721,121.774017,80,'Philippines'],
[51.919438,19.145136,242,'Poland'],
[25.354826,51.183884,86,'Qatar'],
[45.943161,24.96676,35,'Romania'],
[61.52401,105.318756,133,'Russia'],
[23.885942,45.079162,15,'Saudi Arabia'],
[1.352083,103.819836,2,'Singapore'],
[48.669026,19.699024,9,'Slovakia'],
[35.907757,127.766922,41,'South Korea'],
[40.463667,-3.74922,111,'Spain'],
[7.873054,80.771797,97,'Sri Lanka'],
[-6.369028,34.888822,34,'Tanzania'],
[13.443182,-15.310139,129,'Gambia'],
[38.963745,35.243322,2,'Turkey'],
[23.424076,53.847818,85,'United Arab Emirates'],
[55.378051,-3.435973,56,'United Kingdom'],
[48.379433,31.16558,97,'Ukraine'],
[37.09024,-95.712891,130,'United States'],
[6.42375,-66.58973,120,'Venezuela'],
[45.1,15.2,20,'Croatia']
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1, 2, {
calc: function (dt, row) {
return '<div><span>' + dt.getValue(row, 3) + '</span>: ' + dt.getFormattedValue(row, 2) + '</div>';
},
role: 'tooltip',
type: 'string',
p: {html: true}
}]);
var options = {
displayMode: 'markers',
tooltip: {
isHtml: true
}
};
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(view.toDataTable(), options);
}
.google-visualization-tooltip-item:first-child {
display: none;
visibility: hidden;
}
.google-visualization-tooltip-item span {
font-weight: bold;
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="geochart-colors"></div>
Related
Google column charts X-axis label different from value
I'd like to create column chart with X axis numeric values 1, 2, 3, 4 ... N and Y value of course different on every column. I can't find out how to change labels on X line under bars, to string. For example - 1 could be marked as Elephant, 2 as Horse etc. I could use string as X values, but then there is no way to get zoom working. At least, I didn't find any way to get it working. simple example with strings, I'd like to achieve same appearance as this one, but with numeric values on X axis. google.charts.load('current', {packages: ['corechart', 'bar']}); google.charts.setOnLoadCallback(drawBasic); function drawBasic() { var data = new google.visualization.DataTable(); data.addColumn('number', 'animal'); data.addColumn('number', 'count'); data.addRows([ ['Elephant', 5], ['Horse', 2], ['Dog', 7], ['Cat', 4], ]); var options = { explorer: { axis: 'horizontal', keepInBounds: true, }, title: 'Testing', hAxis: { title: 'Animal', }, vAxis: { title: 'number' } }; var chart = new google.visualization.ColumnChart( document.getElementById('chart_div')); chart.draw(data, options); } Chart should look like this, but with working zoom: Chart example
to use string labels on a continuous axis, you will need to provide your own ticks using object notation, provide the value (v:) and formatted value (f:) {v: 1, f: 'Elephant'} see following working snippet... google.charts.load('current', { callback: drawBasic, packages: ['corechart'] }); function drawBasic() { var data = new google.visualization.DataTable(); data.addColumn('number', 'animal'); data.addColumn('number', 'count'); data.addRows([ [1, 5], [2, 2], [3, 7], [4, 4] ]); var options = { explorer: { axis: 'horizontal' }, title: 'Testing', hAxis: { ticks: [ {v: 1, f: 'Elephant'}, {v: 2, f: 'Horse'}, {v: 3, f: 'Dog'}, {v: 4, f: 'Cat'} ], title: 'Animal', }, vAxis: { title: 'number' } }; var chart = new google.visualization.ColumnChart( document.getElementById('chart_div') ); chart.draw(data, options); } <script src="https://www.gstatic.com/charts/loader.js"></script> <div id="chart_div"></div>
Google Charts: Why am I getting two select events when I have animation turned on
I attach a select event to charts -- a column chart and a pie chart When I turn on animation, I get two select events for a single column select action from the column chart (but just one, correctly, from the pie chart, which doesn't animate). For the column chart, the first event returns the correct selection data [{column:1, row:1}], but the second event returns an empty array. With animation turned off (commented out) I get the correct response, namely only one event when a user selects a column. Has anyone seen this? What do I do? I haven't found any value that lets me even differentiate whether the event is occurring in the presence of animation, or any other logical way to at least filter out the rogue second event. Obviously I would like to suppress the incorrect second event when animation is turned on. Here's the animation spec: let options = { animation:{ startup: true, duration: 500, easing: 'out', },
the 'select' event on a ColumnChart seems to be working fine with animation here, see following working snippet... is there more you can share? are you creating the charts directly or using the ChartWrapper class? which packages are you using, 'corechart'? google.charts.load('current', { callback: function () { var data = new google.visualization.DataTable(); data.addColumn('timeofday', 'Time of Day'); data.addColumn('number', 'Motivation Level'); data.addColumn('number', 'Energy Level'); data.addRows([ [{v: [8, 0, 0], f: '8 am'}, 1, .25], [{v: [9, 0, 0], f: '9 am'}, 2, .5], [{v: [10, 0, 0], f:'10 am'}, 3, 1], [{v: [11, 0, 0], f: '11 am'}, 4, 2.25], [{v: [12, 0, 0], f: '12 pm'}, 5, 2.25], [{v: [13, 0, 0], f: '1 pm'}, 6, 3], [{v: [14, 0, 0], f: '2 pm'}, 7, 4], [{v: [15, 0, 0], f: '3 pm'}, 8, 5.25], [{v: [16, 0, 0], f: '4 pm'}, 9, 7.5], [{v: [17, 0, 0], f: '5 pm'}, 10, 10], ]); var view = new google.visualization.DataView(data); view.setColumns([{sourceColumn:0, type: 'string', calc: 'stringify'}, 1]); var options = { animation:{ startup: true, duration: 500, easing: 'out', }, hAxis: { title: 'Time of Day', format: 'h:mm a', viewWindow: { min: [7, 30, 0], max: [17, 30, 0] } }, isStacked: true, title: 'Motivation and Energy Level Throughout the Day', vAxis: { title: 'Rating (scale of 1-10)' } }; var chartCol = new google.visualization.ColumnChart(document.getElementById('column_div')); var chartPie = new google.visualization.PieChart(document.getElementById('pie_div')); google.visualization.events.addListener(chartCol, 'select', function () { showSelection(chartCol); }); google.visualization.events.addListener(chartPie, 'select', function () { showSelection(chartPie); }); function showSelection(sender) { document.getElementById('msg_div').innerHTML += (new Date()).getTime() + ' -- ' + JSON.stringify(sender.getSelection()) + '<br/>'; } chartCol.draw(data, options); chartPie.draw(view, { legend: 'none', theme: 'maximized' }); }, packages: ['corechart'] }); div { padding: 6px 6px 6px 6px; } <script src="https://www.gstatic.com/charts/loader.js"></script> <div id="column_div"></div> <div id="pie_div"></div> <div id="msg_div"></div>
How to change selected column border color & width in Google Charts?
I am using Google Charts. I want to change border color & width of selected column. By default stroke color is white and width is 1. I want to change border color to black and width to 2. Code : var data = google.visualization.arrayToDataTable(mydata); var options = { width: 600, height: 400, legend: {position: 'top', maxLines: 4}, bar: {groupWidth: '50%'}, isStacked: true }; var chart = new google.visualization.ColumnChart(document.getElementById('mydiv')); chart.draw(data, options);
There is no build-in option to set this style, but you may ovveride these settings for stroke-color/width via CSS: google.load('visualization', '1', {packages: ['corechart']}); google.setOnLoadCallback(drawStacked); function drawStacked() { var data = new google.visualization.DataTable(); data.addColumn('timeofday', 'Time of Day'); data.addColumn('number', 'Motivation Level'); data.addColumn('number', 'Energy Level'); data.addRows([ [{v: [8, 0, 0], f: '8 am'}, 1, .25], [{v: [9, 0, 0], f: '9 am'}, 2, .5], [{v: [10, 0, 0], f:'10 am'}, 3, 1], [{v: [11, 0, 0], f: '11 am'}, 4, 2.25], [{v: [12, 0, 0], f: '12 pm'}, 5, 2.25], [{v: [13, 0, 0], f: '1 pm'}, 6, 3], [{v: [14, 0, 0], f: '2 pm'}, 7, 4], [{v: [15, 0, 0], f: '3 pm'}, 8, 5.25], [{v: [16, 0, 0], f: '4 pm'}, 9, 7.5], [{v: [17, 0, 0], f: '5 pm'}, 10, 10], ]); var options = { legend: {position: 'top', maxLines: 4}, isStacked: true}; var chart = new google.visualization.ColumnChart(document.getElementById('mydiv')); chart.draw(data, options); } #mydiv svg>g>g>g>g>rect[stroke="#ffffff"][stroke-width="1"] { stroke: black !important; stroke-width: 2px !important; } <div id="mydiv"></div> <script type="text/javascript" src="https://www.google.com/jsapi"></script>
You could set column style (border color & width) by applying Column styles on the selected column using select event as demonstrated below: google.load("visualization", '1.1', { packages: ['corechart'] }); google.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable([ ['Genre', 'Fantasy & Sci Fi', 'Romance', 'Mystery/Crime', 'General','Western', 'Literature'], ['2010', 10, 24, 20, 32, 18, 5], ['2020', 16, 22, 23, 30, 16, 9], ['2030', 28, 19, 29, 30, 12, 13] ]); var options = { width: 600, height: 400, legend: { position: 'top', maxLines: 3 }, bar: { groupWidth: '75%' }, isStacked: true, }; var view = new google.visualization.DataView(data); var chart = new google.visualization.ColumnChart(document.getElementById('columnchart_stacked')); google.visualization.events.addListener(chart, 'select', function () { highlightBar(chart,options,view); }); chart.draw(data, options); } function highlightBar(chart,options,view) { var selection = chart.getSelection(); if (selection.length) { var row = selection[0].row; var column = selection[0].column; //1.insert style role column to highlight selected column var styleRole = { type: 'string', role: 'style', calc: function(dt, i) { return (i == row) ? 'stroke-color: #000000; stroke-width: 2' : null; } }; var indexes = [0, 1, 2, 3, 4, 5, 6]; var styleColumn = findStyleRoleColumn(view) if (styleColumn != -1 && column > styleColumn) indexes.splice(column, 0, styleRole); else indexes.splice(column+1, 0, styleRole); view.setColumns(indexes); //2.redraw the chart chart.draw(view, options); } } function findStyleRoleColumn(view) { for (var i = 0; i < view.getNumberOfColumns() ; i++) { if (view.getColumnRole(i) == "style") { return i; } } return -1; } <script type="text/javascript" src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization','version':'1.1','packages':['corechart']}]}"></script> <div id="columnchart_stacked" style="width: 600px; height: 420px;"></div> JSFiddle
Google Line Charts, place circle on annotation
i am new to google charts i want to make a graph for cricket rate rate and wicket that should look something like this i have searched google and found out that i might do it with the help of annotations and i have written this code: <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawVisualization); function drawVisualization() { var data = new google.visualization.DataTable(); data.addColumn('number', 'Overs'); data.addColumn('number', 'Run-rate'); data.addColumn({type: 'string', role:'annotation'}); data.addColumn({type: 'string', role:'annotationText'}); data.addRows([ [1, 6, null, null], [2, 6, null, null], [10, 2, null, null], [20, 3.2, null, 'Shoaib Malik'], [21, 3, '2', 'Shahid Afridi'], [30, 4, null, null], [40, 5, 'B', 'This is Point B'], [50, 6, null, null], ]); var options = { title: 'Run Rate', pointSize:0, hAxis: { gridlines: { color: 'transparent' } }, }; new google.visualization.LineChart(document.getElementById('chart_div')). draw(data, options); } </script> </head> <body> <div id="chart_div" style="width: 900px; height: 500px;"></div> </body> </html> and this is the output of the code: now the problem is that i want to show circle like the first image instead of text 2,B i cant do it using pointSize because i want circle where wicket falls, not where the over ends... can any1 tell me how to do this ? either i can replace text with circle or any other way out
You can't replace the text if you want to use the annotation functionality (as the text is what is generated by the annotations). You could use an overlapping data series to show only certain points. Here's an example that shows an overlapping series (I removed the annotations for simplicity, but you can still use them if you want to): function drawVisualization() { var data = new google.visualization.DataTable(); data.addColumn('number', 'Overs'); data.addColumn('number', 'Run-rate'); data.addColumn('boolean', 'Wicket falls'); data.addRows([ [1, 6, false], [2, 6, false], [10, 2, true], [20, 3.2, false], [21, 3, true], [30, 4, true], [40, 5, false], [50, 6, false] ]); // create a DataView that duplicates points on the "Run Rate" series where "Wicket falls" is true var view = new google.visualization.DataView(data); view.setColumns([0, 1, { type: 'number', label: data.getColumnLabel(2), calc: function (dt, row) { // return the value in column 1 when column 2 is true return (dt.getValue(row, 2)) ? dt.getValue(row, 1) : null; } }]); var options = { title: 'Run Rate', pointSize:0, hAxis: { gridlines: { color: 'transparent' } }, series: { 0: { // put any options pertaining to series 0 ("Run-rate") here }, 1: { // put any options pertaining to series 1 ("Wicket Falls") here pointSize: 6, lineWidth: 0 } } }; new google.visualization.LineChart(document.getElementById('chart_div')). // use the view instead of the DataTable to draw the chart draw(view, options); } google.load('visualization', '1', {packages:['corechart'], callback: drawVisualization}); See working example here: http://jsfiddle.net/asgallant/saTWj/
Google Visualization Chart Not Showing First Column
I am having an issue with the Google Visualization API in that some of the data in the chart is not showing. The chart is fairly simple, it has 4 columns and two rows. http://savedbythegoog.appspot.com/?id=ae0853b788af3292b5547a5b7f1224aed76abfff function drawVisualization() { // Create and populate the data table. var data_table = new google.visualization.DataTable(); data_table.addColumn({"type": "date","label": "Date"}); data_table.addColumn({"type": "number","label": "A"}); data_table.addColumn({"type": "number","label": "B"}); data_table.addColumn({"type": "number","label": "C"}); data_table.addRow([{v: new Date(2013, 5, 26)}, {v: 1}, {v: 0}, {v: 0}]); data_table.addRow([{v: new Date(2013, 5, 27)}, {v: 2}, {v: 1}, {v: 0.5}]); var chart = new google.visualization.ColumnChart(document.getElementById('visualization')); chart.draw(data_table, { legend: "bottom" }); } When generated, the chart shows nothing for the first row (2013-5-26), and shows only the values of 2 and 1 for the second row (omitting 0.5). I suspect this could be similar to Google Column Chart Missing data Does anyone have any ideas?
So it seems Google have provided the solution somewhat... https://developers.google.com/chart/interactive/docs/customizing_axes#Discrete_vs_Continuous Help! My chart has gone wonky! My domain axis type is not string but I still want a discrete domain axis: and this makes you terribly upset, then you can do one of the following: Change the type of your first data table column to string. Use a DataView as adapter to convert the type of your first data table column to string: So the solution to the above chart was to add: //Create a DataView from the data_table var dataView = new google.visualization.DataView(data_table); //Set the first column of the dataview to format as a string, and return the other columns [1, 2 and 3] dataView.setColumns([{calc: function(data, row) { return data.getFormattedValue(row, 0); }, type:'string'}, 1, 2, 3]); So the whole function became: function drawVisualization() { var data_table = new google.visualization.DataTable(); data_table.addColumn({"type": "date","label": "Date"}); data_table.addColumn({"type": "number","label": "A"}); data_table.addColumn({"type": "number","label": "B"}); data_table.addColumn({"type": "number","label": "C"}); data_table.addRow([{v: new Date(2013, 5, 26)}, {v: 1}, {v: 0}, {v: 0}]); data_table.addRow([{v: new Date(2013, 5, 27)}, {v: 2}, {v: 1}, {v: 0.5}]); //Create a DataView from the data_table var dataView = new google.visualization.DataView(data_table); //Set the first column of the dataview to format as a string, and return the other columns [1, 2 and 3] dataView.setColumns([{calc: function(data, row) { return data.getFormattedValue(row, 0); }, type:'string'}, 1, 2, 3]); var chart = new google.visualization.ColumnChart(document.getElementById('visualization')); chart.draw(dataView, { legend: "bottom" }); }