using amChart Annotations and tooltips at the same time -
we've been using amcharts in our iot / scada software mango automation several years , happy it.
i have requirement use annotations on charts. want save data chart , annotations disk other users can log in , see annotations. i'm curious know if possible? 1 issue see when in annotation mode there no way go normal view mode without clearing annotation. meaning use mouse on tooltips on chart , see annotations @ same time.
@gerric correct. it's not possible have tooltips , annotations working together.
they want save data chart , annotations disk other users can log in , see annotations. i'm curious know if possible?
for part of question, please see snippet example in how , set annotation chart. ideally chart should have fixed dimensions annotations stay @ same position when re-used.
unfortunately when try use buttons in snippets, error saving data in sessionstorage
. take @ http://codepen.io/team/amcharts/pen/87180663e881a5dc909078b2c17301a5?editors=1010 see working. have in mind you'll need in annotation mode.
also check annotation api information getannotations
, setannotations
.
var chart = amcharts.makechart( "chartdiv", { "type": "serial", "theme": "light", "dataprovider": [ { "country": "usa", "visits": 2025 }, { "country": "china", "visits": 1882 }, { "country": "japan", "visits": 1809 }, { "country": "germany", "visits": 1322 }, { "country": "uk", "visits": 1122 }, { "country": "france", "visits": 1114 }, { "country": "india", "visits": 984 }, { "country": "spain", "visits": 711 }, { "country": "netherlands", "visits": 665 }, { "country": "russia", "visits": 580 }, { "country": "south korea", "visits": 443 }, { "country": "canada", "visits": 441 }, { "country": "brazil", "visits": 395 } ], "valueaxes": [ { "gridcolor": "#ffffff", "gridalpha": 0.2, "dashlength": 0 } ], "gridabovegraphs": true, "startduration": 1, "graphs": [ { "balloontext": "[[category]]: <b>[[value]]</b>", "fillalphas": 0.8, "linealpha": 0.2, "type": "column", "valuefield": "visits" } ], "chartcursor": { "categoryballoonenabled": false, "cursoralpha": 0, "zoomable": false }, "categoryfield": "country", "categoryaxis": { "gridposition": "start", "gridalpha": 0, "tickposition": "start", "ticklength": 20, "labelrotation": 45 }, "export": { "enabled": true } } ); $('#copy-annotation-button').on('click', function () { var amexport = chart.amexport; amexport.getannotations({}, function (data) { window.sessionstorage.setitem("annotation", json.stringify(data)); }); }); $('#paste-annotation-button').on('click', function () { var amexport = chart.amexport, data = json.parse(window.sessionstorage.getitem("annotation")); amexport.setannotations({ data: data }, function () { // }); });
#chartdiv { width: 700px; height: 300px; font-family: arial; }
<link href="https://www.amcharts.com/lib/3/plugins/export/export.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://www.amcharts.com/lib/3/amcharts.js"></script> <script src="https://www.amcharts.com/lib/3/serial.js"></script> <script src="https://www.amcharts.com/lib/3/themes/light.js"></script> <script src="https://www.amcharts.com/lib/3/plugins/export/export.js"></script> <button id="copy-annotation-button">copy annotation</button> <button id="paste-annotation-button">paste annotation</button> <div id="chartdiv"></div>
Comments
Post a Comment