2013-11-28 2 views
0

Мне нужно передать данные хэш-карты json в jqplot, я не хочу преобразовать объект json в массив и перейти к jqplot. Можно ли передать hashmap json в jqplot? Хешмап содержит строку и карту значений.Как передать данные hashmap json в JQPlot?

Map<String, Map<String, Integer>> data; 

Может кто-нибудь предложить некоторые идеи для этого? Спасибо заранее.

ответ

0

Посмотрите на этой странице http://www.jqplot.com/tests/data-renderers.php

$(document).ready(function(){ 
    // Our ajax data renderer which here retrieves a text file. 
    // it could contact any source and pull data, however. 
    // The options argument isn't used in this renderer. 
    var ajaxDataRenderer = function(url, plot, options) { 
    var ret = null; 
    $.ajax({ 
     // have to use synchronous here, else the function 
     // will return before the data is fetched 
     async: false, 
     url: url, 
     dataType:"json", 
     success: function(data) { 
     ret = data; 
     } 
    }); 
    return ret; 
    }; 

    // The url for our json data 
    var jsonurl = "./jsondata.txt"; 

    // passing in the url string as the jqPlot data argument is a handy 
    // shortcut for our renderer. You could also have used the 
    // "dataRendererOptions" option to pass in the url. 
    var plot2 = $.jqplot('chart2', jsonurl,{ 
    title: "AJAX JSON Data Renderer", 
    dataRenderer: ajaxDataRenderer, 
    dataRendererOptions: { 
     unusedOptionalUrl: jsonurl 
    } 
    }); 
}); 
Смежные вопросы