4
有什麼方法可以使用圖表助手在圖表上顯示圖例嗎?ASP.NET MVC 3.0圖表助手顯示圖例
它默認不顯示出來,沒有物業,我可以說顯示,如果我在XML中指定的傳說:
<Legends>
<Legend _Template_=""All"" BackColor=""Black"" Docking=""Bottom"" Font=""Trebuchet MS, 8.25pt, style=Bold"" LegendStyle=""Row"" >
</Legend>
</Legends>
它也不能正常工作。
圖助手public Chart AddLegend(string title = null, string name = null)
中有方法;但是當我打電話時,我看不到圖表上的圖例,圖表也不顯示。
Chart chart = new System.Web.Helpers.Chart(width: 120, height: 300, theme: chartStyle: ChartTheme.Green.ToString())
.AddLegend("title", "name") // not existed legends, that's why error.
.AddSeries(
chartType: "Column"
legend: "Rainfall"
xValue: new[] { "jan", "feb", "mar", "apr", "may" },
yValues: new[] { "20", "20", "40", "10", "10" });
.Getting錯誤:Series 'Series1' uses non-existing legend name 'Rainfall'. Set Legend property value to Default
如果我改變legend: "Rainfall"
到legend: "Default"
得到同樣的錯誤。
我怎麼能讓這個傳說名稱存在?例如,在使用直接的System.Web.UI.DataVisualization.Charting
情況下,它會尋找這樣的:
chart.Legends.Add("Legend1");
// show legend based on check box value
chart.Legends["Legend1"].Enabled = true;
但如何實現與助手同樣的事情?