{"id":1084,"date":"2018-08-16T01:48:15","date_gmt":"2018-08-16T01:48:15","guid":{"rendered":"http:\/\/www.ipcpu.com\/?p=1084"},"modified":"2018-11-07T01:50:46","modified_gmt":"2018-11-07T01:50:46","slug":"echarts-data-dynamic","status":"publish","type":"post","link":"https:\/\/c.ipcpu.com\/2018\/08\/echarts-data-dynamic\/","title":{"rendered":"echarts\u52a8\u6001\u4f20\u503c\u3001\u52a8\u6001\u52a0\u8f7d\u6570\u636e"},"content":{"rendered":"

\u4e00\u3001echarts\u6570\u636e\u4f20\u5165\u7684\u4e24\u79cd\u65b9\u5f0f<\/h2>\n

\u5728echarts\u4e2d\uff0c\u6211\u4eec\u8bbe\u5b9aX\u8f74\u3001Y\u8f74\u6570\u636e\u7684\u65b9\u5f0f\u6709\u4e24\u79cd <\/p>\n

\u65b9\u6cd5\u4e00\u3001\u5206\u522b\u8bbe\u7f6eX\u8f74\u7684data\u5c5e\u6027\u548cseries\u7684\u5c5e\u6027\uff0c\u5982\u4e0b<\/h4>\n

<\/p>\n

\u65b9\u6cd5\u4e8c\uff1a\u5c06X\u8f74\u6570\u636e\u548cY\u8f74\u6570\u636e\u90fd\u5199\u5165\u5230series\u5c5e\u6027\uff0c\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u5982\u4e0b<\/h4>\n


\n\u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u4e0b\uff0c\u5b57\u7b26\u4e32\u9700\u8981\u52a0\u4e0a\u5f15\u53f7\u3002\u4e24\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\u753b\u51fa\u4ee5\u4e0b\u56fe\u50cf\uff0c
\n<\/p>\n

\u4e8c\u3001\u51c6\u5907JSON\u6570\u636e<\/h2>\n

\u6211\u4eec\u4f7f\u7528Ajax\u52a8\u6001\u4f20\u9012\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u628aX\u8f74\u3001Y\u8f74\u6570\u636e\u5206\u5f00\u6216\u8005\u5408\u5728\u4e00\u8d77\u3002
\n\u4f8b\u5982\uff0c\u6211\u4eec\u7684\u63a5\u53e3\u4f20\u9012\u7684\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n

\n
{\"countData\":[['2018-02-15',665445],['2018-02-16',665445],['2018-02-17',56532]]}<\/code><\/pre>\n<\/div>\n

\u4e09\u3001AJAX\u4ee3\u7801<\/h2>\n

\u90a3\u4e48Ajax\u4ee3\u7801\u5982\u4e0b,<\/p>\n

\n
                $.ajax({\r\n                  url: \"\/getCDNBandwidth\",\r\n                  type: 'POST',\r\n                  dataType: 'json',\r\n                  error: function (request, error) {\r\n                      console.log(\" Can't do because: \" + error);\r\n                  },\r\n                  success: function (res) {\r\n                      if (res) {\r\n                          option.series[0].data = res.countData;\r\n                          myChart.setOption(option);\r\n                      }\r\n                  }\r\n                });<\/code><\/pre>\n<\/div>\n

<\/p>\n

<\/div>\n
<\/div>\n
\n
<\/div>\n
<\/div>\n
<\/div>\n
<\/div>\n
<\/div>\n<\/div>\n
\n
<\/div>\n
<\/div>\n
<\/div>\n
<\/div>\n
<\/div>\n<\/div>\n

<\/wiz_tmp_tag><\/p>\n

\u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def<\/a> » echarts\u52a8\u6001\u4f20\u503c\u3001\u52a8\u6001\u52a0\u8f7d\u6570\u636e<\/a><\/p>","protected":false},"excerpt":{"rendered":"

\u4e00\u3001echarts\u6570\u636e\u4f20\u5165\u7684\u4e24\u79cd\u65b9\u5f0f \u5728echarts\u4e2d\uff0c\u6211\u4eec\u8bbe\u5b9aX\u8f74\u3001Y\u8f74\u6570\u636e\u7684\u65b9\u5f0f\u6709\u4e24\u79cd \u65b9\u6cd5\u4e00\u3001\u5206\u522b\u8bbe\u7f6eX\u8f74\u7684data\u5c5e\u6027\u548cseries\u7684\u5c5e\u6027\uff0c\u5982\u4e0b \u65b9\u6cd5\u4e8c\uff1a\u5c06X\u8f74\u6570\u636e\u548cY\u8f74\u6570\u636e\u90fd\u5199\u5165\u5230series\u5c5e\u6027\uff0c\u4ee5\u6570\u7ec4\u7684\u5f62\u5f0f\u5b58\u5728\uff0c\u5982\u4e0b \u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u4e0b\uff0c\u5b57\u7b26\u4e32\u9700\u8981\u52a0\u4e0a\u5f15\u53f7\u3002\u4e24\u79cd\u65b9\u6cd5\u90fd\u53ef\u4ee5\u753b\u51fa\u4ee5\u4e0b\u56fe\u50cf\uff0c \u4e8c\u3001\u51c6\u5907JSON\u6570\u636e \u6211\u4eec\u4f7f\u7528Ajax\u52a8\u6001\u4f20\u9012\u6570\u636e\u65f6\uff0c\u53ef\u4ee5\u628aX\u8f74\u3001Y\u8f74\u6570\u636e\u5206\u5f00\u6216\u8005\u5408\u5728\u4e00\u8d77\u3002 \u4f8b\u5982\uff0c\u6211\u4eec\u7684\u63a5\u53e3\u4f20\u9012\u7684\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a {“countData”:[[‘2018-02-15’,665445],[‘2018-02-16’,665445],[‘2018-02-17’,56532]]} \u4e09\u3001AJAX\u4ee3\u7801 \u90a3\u4e48Ajax\u4ee3\u7801\u5982\u4e0b, $.ajax({ url: “\/getCDNBandwidth”, type: ‘POST’, dataType: ‘json’, error: function (request, error) { console.log(” Can’t do because: ” + error); }, success: function (res) { if (res) { option.series[0].data = res.countData; myChart.setOption(option); } } }); \u8f6c\u8f7d\u8bf7\u6ce8\u660e\uff1aIPCPU-\u7f51\u7edc\u4e4b\u8def » echarts\u52a8\u6001\u4f20\u503c\u3001\u52a8\u6001\u52a0\u8f7d\u6570\u636e<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[180,10,12],"_links":{"self":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1084"}],"collection":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/comments?post=1084"}],"version-history":[{"count":2,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1084\/revisions"}],"predecessor-version":[{"id":1087,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/posts\/1084\/revisions\/1087"}],"wp:attachment":[{"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/media?parent=1084"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/categories?post=1084"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c.ipcpu.com\/wp-json\/wp\/v2\/tags?post=1084"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}