ASP.NET 图表 - 数据绑定值、自定义标签
我有一个 ASP.NET C# 数据绑定图表。数据绑定字段之一是文本,另一个是值。我希望图例显示饼图的文本,并且希望该值确定图表的形成方式,并在饼图的每块上显示为标签。
这是我到目前为止的代码:
<asp:Chart ID="consignedChart" runat="server" DataSourceID="SqlDataSource4"
BackColor="LightSlateGray" Palette="None"
PaletteCustomColors="LightSeaGreen; SteelBlue" Width="400px" >
<Series>
<asp:Series Name="Series1" ChartType="Pie" XValueMember="Owner"
YValueMembers="TotalValue" Legend="Legend1" >
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="true" BackColor="LightSlateGray">
<Area3DStyle Enable3D="True" LightStyle="Realistic"/>
</asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Name="Legend1">
</asp:Legend>
</Legends>
</asp:Chart>
编辑
这是一张图片,它可能会让它更容易理解。红色框中的标签是我想要更改以显示值编号的标签。
I have a databound chart in ASP.NET C#. One of the databound fields is text and the other is a value. I would like the legend to display the text for the pie chart, and I would like the value to determine how the chart is formed, and also display as a label on each piece of the pie chart.
Here is the code I have so far:
<asp:Chart ID="consignedChart" runat="server" DataSourceID="SqlDataSource4"
BackColor="LightSlateGray" Palette="None"
PaletteCustomColors="LightSeaGreen; SteelBlue" Width="400px" >
<Series>
<asp:Series Name="Series1" ChartType="Pie" XValueMember="Owner"
YValueMembers="TotalValue" Legend="Legend1" >
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="true" BackColor="LightSlateGray">
<Area3DStyle Enable3D="True" LightStyle="Realistic"/>
</asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Name="Legend1">
</asp:Legend>
</Legends>
</asp:Chart>
EDIT
Here is an image, it might make it easier to understand. The labels in the red boxes are the ones I want changed to display the value number.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这个答案可能来得太晚了,请不要为此烦恼:)
我不确定您如何绑定数据,但我下载并安装了适用于 Windows 窗体示例环境的 Microsoft Chart,我可以从中学到很多东西。
这里是一个链接,您还可以从 MSDN 获取 asp.net 示例档案。
我还使用 ILSpy 查看 System.Windows.Forms.DataVisualization.Charting 中的代码命名空间。这样你就可以找到很多没有记录的东西。
最后,这里有一些 winform 代码示例,您可以从中得出一些关于您的问题的想法,然后将其写入 asp.net 标记:
希望有所帮助。
I am aware this answer might come a little too late, please don't fry me for that :)
I'm not sure how you bind your data, but I downloaded and installed the Microsoft Chart for Windows Forms Samples Environment, and I could learn a lot from that.
Here is a link where you can get also asp.net samples from MSDN archives.
I am also using ILSpy to look at the code in the System.Windows.Forms.DataVisualization.Charting namespace. This way you can find about a lot of undocumented things.
Finally, here's some winform code sample from which you could draw some idea for your issue, and then write it in asp.net markup:
Hope that helps.