Reputation: 31
I want to use Google Charts API to create an Annotated Chart like the one on the example page: https://developers.google.com/chart/interactive/docs/gallery/annotationchart
However, my data is not in a date format, it is two columns each containing a number which do not represent time.
When I try to draw my chart I receive an error message stating that the first column must be a date or datetime format.
I tried to get around the problem by changing the first column to:
new Date(0,0,MyNumber)
the chart draws my data but the x-axis labels are all dates which I don't want! How can I get the labels to be my numbers?
Upvotes: 0
Views: 282
Reputation: 41
To deal with js files I found that there are 2 functions and one variable which needs to be changed. I updated these values manually by yourself and it worked for me
gvjs__a = "number";
gvjs_OD = function (a){return a;};
gvjs_uj = function (a,b,c){return c;}
for example see code below
google.charts.load('current', {'packages':['annotationchart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
**data.addColumn('number', 'TestDate');**
data.addColumn('number', 'Kepler-22b mission');
data.addRows([
[13, 12400],
[16, 24045]
]);
var chart = new google.visualization.AnnotationChart(document.getElementById('chart_div'));
var formatter_long = new google.visualization.DateFormat({formatType: 'long'});
var formatter = new google.visualization.DateFormat({pattern: "yy"});
formatter_long.format(data, 0);
var options = {
displayAnnotations: true
};
gvjs__a = "number";
gvjs_OD = function (a){return a;};
gvjs_uj = function (a,b,c){return c;}
chart.draw(data, options);
}
Upvotes: 0