{"id":230735,"date":"2021-11-28T09:58:19","date_gmt":"2021-11-28T01:58:19","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=230735"},"modified":"2021-11-24T09:59:08","modified_gmt":"2021-11-24T01:59:08","slug":"to-chart-helper","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/to-chart-helper.html","title":{"rendered":"ASP.NET Web Pages – Chart \u5e2e\u52a9\u5668\u7b80\u4ecb"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nWeb \u5e2e\u52a9\u5668\u5927\u5927\u7b80\u5316\u4e86 Web \u5f00\u53d1\u548c\u5e38\u89c1\u7684\u7f16\u7a0b\u4efb\u52a1\u3002Chart \u5e2e\u52a9\u5668\u662f\u4f17\u591a\u6709\u7528\u7684 ASP.NET Web \u5e2e\u52a9\u5668\u4e4b\u4e00\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
Chart \u5e2e\u52a9\u5668<\/strong><\/div>\n

\"Chart \u5e2e\u52a9\u5668\" \u53ef\u4ee5\u521b\u5efa\u4e0d\u540c\u7c7b\u578b\u7684\u5e26\u6709\u591a\u79cd\u683c\u5f0f\u5316\u9009\u9879\u548c\u6807\u7b7e\u7684\u56fe\u8868\u56fe\u50cf\u3002\u5b83\u53ef\u4ee5\u521b\u5efa\u9762\u79ef\u56fe\u3001\u6761\u5f62\u56fe\u3001\u67f1\u5f62\u56fe\u3001\u6298\u7ebf\u56fe\u3001\u997c\u56fe\u7b49\u6807\u51c6\u56fe\u8868\uff0c\u4e5f\u53ef\u4ee5\u521b\u5efa\u50cf\u80a1\u7968\u56fe\u8868\u8fd9\u6837\u7684\u66f4\u4e13\u4e1a\u7684\u56fe\u8868\u3002<\/p>\n

\"\"\"\"<\/p>\n

\u5728\u56fe\u8868\u4e2d\u663e\u793a\u7684\u6570\u636e\u53ef\u4ee5\u662f\u6765\u81ea\u4e00\u4e2a\u6570\u7ec4\uff0c\u4e00\u4e2a\u6570\u636e\u5e93\uff0c\u6216\u8005\u4e00\u4e2a\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u3002<\/p>\n

\u6839\u636e\u6570\u7ec4\u521b\u5efa\u56fe\u8868<\/strong><\/div>\n

\u4e0b\u9762\u7684\u5b9e\u4f8b\u663e\u793a\u4e86\u6839\u636e\u6570\u7ec4\u6570\u636e\u663e\u793a\u56fe\u8868\u6240\u9700\u7684\u4ee3\u7801\uff1a<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

@{ \r\nvar myChart = new Chart(width: 600, height: 400) \r\n  \r\n.AddTitle(\"Employees\") \r\n  \r\n.AddSeries(chartType: \"column\",\r\n      xValue: new[] {  \"Peter\", \"Andrew\", \"Julie\", \"Mary\", \"Dave\" },\r\n      yValues: new[] { \"2\", \"6\", \"4\", \"5\", \"3\" }) \r\n  \r\n.Write();\r\n}<\/span><\/pre>\n

- new Chart \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u56fe\u8868\u5bf9\u8c61\u5e76\u4e14\u8bbe\u7f6e\u5b83\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6<\/p>\n

- AddTitle \u65b9\u6cd5\u6307\u5b9a\u4e86\u56fe\u8868\u7684\u6807\u9898<\/p>\n

- AddSeries \u65b9\u6cd5\u5411\u56fe\u8868\u4e2d\u589e\u52a0\u6570\u636e<\/p>\n

- chartType \u53c2\u6570\u5b9a\u4e49\u56fe\u8868\u7684\u7c7b\u578b<\/p>\n

- xValue \u53c2\u6570\u5b9a\u4e49 x \u8f74\u7684\u540d\u79f0<\/p>\n

- yValues \u53c2\u6570\u5b9a\u4e49 y \u8f74\u7684\u540d\u79f0<\/p>\n

- Write() \u65b9\u6cd5\u663e\u793a\u56fe\u8868<\/p>\n

\u6839\u636e\u6570\u636e\u5e93\u521b\u5efa\u56fe\u8868<\/strong><\/div>\n

\u60a8\u53ef\u4ee5\u6267\u884c\u4e00\u4e2a\u6570\u636e\u5e93\u67e5\u8be2\uff0c\u7136\u540e\u4f7f\u7528\u67e5\u8be2\u7ed3\u679c\u4e2d\u7684\u6570\u636e\u6765\u521b\u5efa\u4e00\u4e2a\u56fe\u8868\uff1a<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

@{ \r\nvar db = Database.Open(\"SmallBakery\");\r\nvar dbdata = db.Query(\"SELECT Name, Price FROM Product\"); \r\nvar myChart = new Chart(width: 600, height: 400) \r\n   .AddTitle(\"Product Sales\") \r\n   .DataBindTable(dataSource: dbdata, xField: \"Name\")\r\n   .Write();\r\n}<\/span><\/pre>\n

- var db = Database.Open \u6253\u5f00\u6570\u636e\u5e93\uff08\u5c06\u6570\u636e\u5e93\u5bf9\u8c61\u8d4b\u503c\u7ed9\u53d8\u91cf db\uff09<\/p>\n

- var dbdata = db.Query \u6267\u884c\u6570\u636e\u5e93\u67e5\u8be2\u5e76\u4fdd\u5b58\u7ed3\u679c\u5728 dbdata \u4e2d<\/p>\n

- new Chart \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u56fe\u8868\u5bf9\u8c61\u5e76\u4e14\u8bbe\u7f6e\u5b83\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6<\/p>\n

- AddTitle \u65b9\u6cd5\u6307\u5b9a\u4e86\u56fe\u8868\u7684\u6807\u9898<\/p>\n

- DataBindTable \u65b9\u6cd5\u5c06\u6570\u636e\u6e90\u7ed1\u5b9a\u5230\u56fe\u8868<\/p>\n

- Write() \u65b9\u6cd5\u663e\u793a\u56fe\u8868<\/p>\n

\u9664\u4e86\u4f7f\u7528 DataBindTable \u65b9\u6cd5\u4e4b\u5916\uff0c\u53e6\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528 AddSeries\uff08\u89c1\u524d\u9762\u7684\u5b9e\u4f8b\uff09\u3002DataBindTable \u66f4\u5bb9\u6613\u4f7f\u7528\uff0c\u4f46\u662f AddSeries \u66f4\u52a0\u7075\u6d3b\uff0c\u56e0\u4e3a\u60a8\u53ef\u4ee5\u66f4\u660e\u786e\u5730\u6307\u5b9a\u56fe\u8868\u548c\u6570\u636e\uff1a<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

@{ \r\nvar db = Database.Open(\"SmallBakery\"); \r\nvar dbdata = db.Query(\"SELECT Name, Price FROM Product\"); \r\nvar myChart = new Chart(width: 600, height: 400) \r\n   .AddTitle(\"Product Sales\") \r\n   .AddSeries(chartType:\"Pie\",\r\n      xValue: dbdata, xField: \"Name\",\r\n      yValues: dbdata, yFields: \"Price\")\r\n   .Write();\r\n}<\/span><\/pre>\n
\u6839\u636e XML \u6570\u636e\u521b\u5efa\u56fe\u8868<\/strong><\/div>\n

\u7b2c\u4e09\u79cd\u521b\u5efa\u56fe\u8868\u7684\u65b9\u6cd5\u662f\u4f7f\u7528 XML \u6587\u4ef6\u4f5c\u4e3a\u56fe\u8868\u7684\u6570\u636e\uff1a<\/p>\n

\u5b9e\u4f8b<\/strong><\/p>\n

\r\n@using System.Data;\r\n@{\r\nvar dataSet = new DataSet();\r\ndataSet.ReadXmlSchema(Server.MapPath(\"data.xsd\"));\r\ndataSet.ReadXml(Server.MapPath(\"data.xml\"));\r\nvar dataView = new DataView(dataSet.Tables[0]);\r\nvar myChart = new Chart(width: 600, height: 400)\r\n  \r\n.AddTitle(\"Sales Per Employee\")\r\n  \r\n.AddSeries(\"Default\", chartType: \"Pie\",\r\n     \r\nxValue: dataView, xField: \"Name\",\r\n     \r\nyValues: dataView, yFields: \"Sales\")\r\n  \r\n.Write();}\r\n}<\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"

“Chart \u5e2e\u52a9\u5668” \u53ef\u4ee5\u521b\u5efa\u4e0d\u540c\u7c7b\u578b\u7684\u5e26\u6709\u591a\u79cd\u683c\u5f0f\u5316\u9009\u9879\u548c\u6807\u7b7e\u7684\u56fe\u8868\u56fe\u50cf\u3002\u5b83\u53ef\u4ee5\u521b\u5efa\u9762\u79ef\u56fe\u3001\u6761\u5f62\u56fe\u3001\u67f1\u5f62\u56fe […]<\/p>\n","protected":false},"author":1470,"featured_media":230740,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-230735","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\/230735","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\/1470"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=230735"}],"version-history":[{"count":4,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/230735\/revisions"}],"predecessor-version":[{"id":230742,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/230735\/revisions\/230742"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/230740"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=230735"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=230735"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=230735"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}