ruby-on-railsgoogle-visualizationchartkick

Add annotations with Chartkick


I want to add annotations to my time series chart. From Google's documentation: data.addColumn({type:'string', role:'annotation'});

How can I pass these column properties through Chartkick?

<%= line_chart [{name: 'annotations', data: annotations_array},{name: 'numbers as a time series', data: 'numeric_array'}] %>


Solution

  • I created a pull request to the chartkick.js repo to add the functionality you're describing.

    https://github.com/ankane/chartkick.js/pull/58

    This is just for the JS library (chartkick.js), but the approach can be used in the ruby library by using the modified chartkick.js from this pull request and passing in the right role values (certainty, annotation, etc.) to the library options.

    var data = [..., [Sat Mar 05 2016 17:13:22 GMT-0800 (PST), 1, false, "cool annotation"]];
    new Chartkick.LineChart("chart-1", data, {
                "library": 
                  {"role":["certainty", "annotation"]}
                });