The following code creates a Sparklines pie chart from a JSON string:
//Display Visitor Screen Size Stats
$.getJSON('models/ucp/traffic/traffic_display_bos.php',
{
type: 'ss',
server: server,
api: api,
ip: ip,
},
function(data)
{
//alert(data.screens);
$('#traffic_bos_ss').sparkline(data.views,
{
type: "pie",
height: "100%",
tooltipFormat: "{{offset:offset}} - {{value}}",
tooltipValueLookups:
{
'offset': data.screens;
}
});
});
The pie chart is successfully created, however, I'm having trouble with assigning the correct labels to the offset. The JSON string that is called is as follows:
{"screens":"{ 0: '1220x1080', 1: '1620x1080', 2: '1920x1080' }", "views":[2, 2, 61]}
I want it so that the screens of the JSON is inserted in the offset (data.screens). It should become:
tooltipValueLookups:
{
'offset': { 0: '1220x1080', 1: '1620x1080', 2: '1920x1080' }
}
How can this be accomplished?