i'm trying use datamaps charting library , came across notation data:
var map = new datamap({ element: document.getelementbyid('container'), fills: { high: '#afafaf', low: '#123456', medium: 'blue', unknown: 'rgb(0,0,0)', defaultfill: 'green' }, data: { irl: { fillkey: 'low', numberofthings: 2002 }, usa: { fillkey: 'medium', numberofthings: 10381 } } });
if want place object in "data" attribute, cannot - because country code not wrapped in quotes.
how build data such scenarios?
[edit]
here's json create in controller , send using rest callout:
{"usa":{"value":"15000.0","countryname":"usa"}}
i changing following match way library accepts data:
{usa:{fillkey : 'low'}}
for using json.parse(), needs data in proper json format, like:
{"usa":{"fillkey" : "low"}}
(note absence of quotes around usa)
currently, i'm using create datamap:
var dataforchart = builddataforchart();// outputs string "{usa:{fillkey : 'low'}}" var map = new datamap({ element: document.getelementbyid('container'), fills: { high: '#afafaf', low: '#123456', medium: 'blue', unknown: 'rgb(0,0,0)', defaultfill: 'green' }, data: dataforchart });
but doesn't seem work.
try
var options = { element: ..., fills: ..., data: { irl: { fillkey: 'low', numberofthings: 2002 }, usa: { fillkey: 'medium', numberofthings: 10381 } } } options.data.can = { fillkey: 'high', numberofthings: 4201 }; var map = new datamap(options);
Comments
Post a Comment