dongmaoxi0477 2014-04-15 07:26
浏览 68

jQuery绘制图表json数据

I have a problem with jQuery plot chart it works fine but when I load data from php and json it doesnt work it show me nothing.

This is my result from php

[{"label":"Patrik","data":4},{"label":"Miroslav","data":28}]

And flot

            $.getJSON( "http://"+window.location.hostname+"/dashboard/getChartData", function( data ) {
            console.log(data);

            var options = {
                series: {
                    bars: {
                        show: true
                    }
                },
                bars: {
                    align: "center",
                    barWidth: 0.5
                },
                xaxis: {
                    ticks: data.title
                },
                legend: {
                    noColumns: 0,
                    labelBoxBorderColor: "#fff",
                    position: "nw"
                },
                grid: {
                    hoverable: true,
                    borderWidth: 1,
                    borderColor: "#cecece",
                    backgroundColor: { colors: ["#ffffff", "#EDF5FF"] }
                }
            };

            $.plot($("#chart_1_1"), [ data ], options);
        });
  • 写回答

1条回答 默认 最新

  • duanjia4220 2014-04-15 07:30
    关注

    The Json Data that You Receive needs to be converted to Array of arrays Format [[key,value],[key,value]] before you can give it to jqplot. Currently You are having array of objects

    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题