[英]Add a button inside chart control
我想要一個放在圖表內的按鈕,將圖形導出到excel文件。 我搞亂了MapAreas,但我無法弄清楚如何將地圖區域設置為圖像或控件。 有沒有不同的方法來完成此功能? 按鈕需要以某種方式附加到圖表。
您需要了解ASP.NET圖表控件只是一個圖像,當您創建MapAreas時,您基本上指定了此圖像上的可點擊點,因此(據我所知),MapArea不能具有自定義背景圖像或自定義控件。
而是使用自定義圖例:
資源:
<asp:Chart ID="Chart1" runat="server" OnClick="Chart1_Click1">
<Series>
<asp:Series YValuesPerPoint="2" IsVisibleInLegend="false" Name="Series1" ChartType="Column">
<Points>
<asp:DataPoint AxisLabel="Product 1" YValues="100" />
<asp:DataPoint AxisLabel="Product 2" YValues="300" />
</Points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1">
</asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Title="Export options:">
<CustomItems>
<asp:LegendItem
Name="Export To Excel"
PostBackValue="Export From Legend"
Color="Green">
</asp:LegendItem>
</CustomItems>
</asp:Legend>
</Legends>
</asp:Chart>
代碼背后:
protected void Chart1_Click1(object sender, ImageMapEventArgs e)
{
if (e.PostBackValue == "Export From Legend")
{
//Handle the exporting to Excel
}
}
最終結果:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.