I have data about earnings occurred on some dates:
['2013-02-13',100],['2013-03-20',200],['2013-04-11',160]
and data about costs occurred on some other dates:
['2013-02-22',60],['2013-03-04',90],['2013-03-25',110]
So X-axis is continuous one (date), and Y-axis represents earning/cost values (number). I'd like to represent these two date-value series on the same chart. They share the same timeline but events occurred on different dates?
Is this possible?
Yes, you just need to join the two data sets, using the google.visualization.data.join method:
var joinedData = google.visualization.data.join(data1, data2, 'full', [[0, 0]], [1], [1]);
If you draw a chart using this method, you will have two series of data that can be charted together. See this example: http://jsfiddle.net/asgallant/XF7JE/
Incidentally, with your dates input like that, you will get a discrete axis, not a continuous axis. You need to input the dates as javascript Date objects to get a continuous axis.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With