我希望有一个按钮放在图表内部,用于将图表导出为Excel文件。我尝试过使用MapAreas,但无法确定如何将地图区域设置为图像或控件。是否有其他方法来实现这个功能?该按钮需要与图表相关联。
<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
}
}
最终结果: