Как передать хэш-карту данных JSON в JQPlot?

0

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

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

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

Теги:
jqplot

1 ответ

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
    }
  });
});

Ещё вопросы

Сообщество Overcoder
Наверх
Меню