Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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'}] %>

like image 829
sso777 Avatar asked Sep 05 '25 17:09

sso777


1 Answers

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"]}
            });
like image 77
Armando Canals Avatar answered Sep 07 '25 11:09

Armando Canals