开发者

Google visualization p property from JSON

开发者 https://www.devze.com 2023-04-07 23:01 出处:网络
开发者_如何转开发I wonder how the p-property is supposed to work when sending JSON table row and column data to render.
开发者_如何转开发

I wonder how the p-property is supposed to work when sending JSON table row and column data to render.

I try to send {"p":{"title":"This is the title"}} but I can't get it to work.

Is it possible to set graph configuration options from JSON response?

Best regards,

Niclas


Found a solution. Don't know if it is the best out there but it works.

On the server. Add p properties to the JSON data. In this case 'title'.

function drawChart() {

          var jsonData = $.ajax({
          url: "/statistics/getData",
          dataType:"json",
          async: false
          }).responseText;

          var data = new google.visualization.DataTable(jsonData);

          var title = data.getTableProperty("title");

          var chart = new google.visualization.ColumnChart(
          document.getElementById('chart_div'));
          chart.draw(data, {'title':title,
          'width':800,'height':300});
 }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号