I have a google chart (set up using chartkick And I am trying to make the dates appear shorter on the chart. My Data set looks something like this:
{"03/01/13" : 3, "03/02/13" : 0, "03/03/13" : 10 } //etc.
However, when I load up the chart the date is formatted like so: Mar 1, 2013. How can I get the date to appear as I passed it, or in some other short format? The longer fields looked very cramped on the page I am using it on.
Double-click the chart you want to change. At the right, click Setup. Select the cells you want to include in your chart. Optional: To add more data to the chart, click Add another range.
The Legend is hidden by setting the legend property to none in the Google Chart Options. title: 'USA City Distribution', legend: 'none' // Hides the Legend.
What's happening now is that the chart takes your string, parses it to a Javascript Date object, and then uses the chart's default display options to show the date.
According to the Google Charts Docs, you can pass an option format
to the axes using the ICU Pattern Set. So for example, you would specify hAxis.format = "MM/dd/yy"
to get "03/03/13"
.
Using Chartkick, you should be able to use the :library
syntax to pass options.
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