我想要一个放置在图表内的按钮,以将图表导出到 Excel 文件。我搞砸了 MapAreas,但我不知道如何将地图区域设置为图像或控件。有没有不同的方法来完成这个功能?该按钮需要以某种方式附加到图表上。
问问题
2018 次
1 回答
0
You need to understand that an ASP.NET chart control is just an image and when you create MapAreas you basically specify clickable spots on this image, therefore (as far as I know) a MapArea cannot have a custom background image or a custom control.
Instead use a custom legend:
Source:
<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>
Code behind:
protected void Chart1_Click1(object sender, ImageMapEventArgs e)
{
if (e.PostBackValue == "Export From Legend")
{
//Handle the exporting to Excel
}
}
End result:
于 2012-11-08T20:07:52.500 回答