2.\u5b9a\u65f6\u5237\u65b0\u9875\u9762\u7684\u6837\u4f8b<\/strong><\/span><\/div>\n\u8fd9\u91cc\u9762\u4f7f\u7528chartist\u54cd\u5e94\u5f0f\u56fe\u6807\u4f5c\u4e3a\u6848\u4f8b\uff0c\u8bbe\u5b9a\u6bcf15s\u4e2d\u5bf9\u56fe\u8868\u8fdb\u884c\u4e00\u6b21\u5237\u65b0\u3002<\/p>\n
HTML5\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n
< div id=\"headline-chart\" class=\"ct-chart\">< \/div><\/pre>\njQuery\u4ee3\u7801\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n
setInterval(function () {\r\n $.ajax(\r\n {\r\n type:\"GET\",\r\n url:\"\/ajax_loadavg\",\r\n dataType:\"json\",\r\n success:function (data) {\r\n json_data = data\r\n \r\n data = {\r\n labels: [0, 10, 20, 30, 40, 50, 60],\r\n series: [\r\n [1, 2, 3, 4, 0, 0, 0],\r\n [0, 0, 0, 0, 0, 0, 0],\r\n [0, 0, 0, 0, 0, 0, 0],\r\n ]\r\n };\r\n \r\n options = {\r\n height: 300,\r\n showArea: true,\r\n showLine: false,\r\n showPoint: false,\r\n fullWidth: true,\r\n axisX: {\r\n showGrid: false,\r\n showLabel: false\r\n },\r\n lineSmooth: false,\r\n };\r\n \r\n new Chartist.Line('#headline-chart', data, options);\r\n }\r\n },15000)<\/pre>\nDjango \u89c6\u56fe\uff08view\uff09\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n
\u6ce8\u610f\uff1a\u6b64\u5904\u53ea\u662f\u5c55\u793aAjax\u4e0eDjango\u5982\u4f55\u8fdb\u884c\u4ea4\u4e92\uff0cAjax\u83b7\u53d6\u7684JSON\u6570\u636e\u5e76\u672a\u8fdb\u884c\u5229\u7528\uff01<\/p>\n
@csrf_exempt\r\ndef ajax_loadavg(request):\r\n if request.method == 'GET':\r\n context = {'output_loadavg':output_loadavg}\r\n return HttpResponse(json.dumps(context))<\/pre>\nurl\u914d\u7f6e<\/p>\n
path('ajax_loadavg\/', views.ajax_loadavg, name='ajax_loadavg'),<\/pre>\n3.\u5c55\u793a\u6548\u679c<\/strong><\/span><\/div>\n\u53ef\u4ee5\u66ff\u6362series\u90e8\u5206\u7684\u6570\u636e\uff0c\u8fdb\u884c\u5c55\u793a<\/p>\n
<\/p>\n
\u611f\u5174\u8da3\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5\u53c2\u770b\uff0c\u4e5f\u5e0c\u671b\u6709\u60f3\u6cd5\u7684\u5c0f\u4f19\u4f34\uff0c\u8bc4\u8bba\u533a\u591a\u591a\u53d1\u8868\u610f\u89c1\uff01\uff01\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5206\u4eab\u4e00\u4e0b\u6700\u8fd1\u5728\u5b66\u4e60Django\u8fc7\u7a0b\u4e2d\uff0c\u9047\u5230\u548c\u89e3\u51b3\u7684\u4e00\u4e9b\u6709\u8da3\u7684\u65b9\u6cd5\u548c\u95ee\u9898 Django\u4e5f\u4e0d\u7528\u5728\u8fc7\u591a\u7684\u53bb\u4ecb\u7ecd\u4e86\u3002\u4f7f […]<\/p>\n","protected":false},"author":362,"featured_media":112352,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-256117","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/256117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/362"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=256117"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/256117\/revisions"}],"predecessor-version":[{"id":256121,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/256117\/revisions\/256121"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/112352"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=256117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=256117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=256117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}