具有 ASP.NET 图表类型“列”的 MS 图表如果图表中的条形超过 9 个,则不显示轴 x 标签
我对 MS Chart 图表类型列有疑问。如果图表中的条形超过 9 个,则 x 轴标签将无法正确显示,其中一些标签会消失。
这是我对图表的标记:
<asp:Chart ID="chtNBAChampionships" runat="server">
<Series>
<asp:Series Name="Championships" YValueType="Int32" Palette="Berry" ChartType="Column" ChartArea="MainChartArea" IsValueShownAsLabel="true">
<Points>
<asp:DataPoint AxisLabel="Celtics" YValues="17" />
<asp:DataPoint AxisLabel="Lakers" YValues="15" />
<asp:DataPoint AxisLabel="Bulls" YValues="6" />
<asp:DataPoint AxisLabel="Spurs" YValues="4" />
<asp:DataPoint AxisLabel="76ers" YValues="3" />
<asp:DataPoint AxisLabel="Pistons" YValues="3" />
<asp:DataPoint AxisLabel="Warriors" YValues="3" />
<asp:DataPoint AxisLabel="Mara" YValues="4" />
<asp:DataPoint AxisLabel="Saza" YValues="9" />
<asp:DataPoint AxisLabel="Buha" YValues="6" />
</Points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="MainChartArea">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
只有 9 根柱线时它可以工作,但我不知道为什么超过 9 根柱线时它会失败。有什么办法可以让图表正常工作吗?另外,如果可能的话,如何使每个条具有不同的颜色?
I have a problem with an MS Chart chart type column. If there are more than 9 bars in the chart, the axis-x labels won't show up properly, some of them just disappear.
Here's my mark-up for the chart:
<asp:Chart ID="chtNBAChampionships" runat="server">
<Series>
<asp:Series Name="Championships" YValueType="Int32" Palette="Berry" ChartType="Column" ChartArea="MainChartArea" IsValueShownAsLabel="true">
<Points>
<asp:DataPoint AxisLabel="Celtics" YValues="17" />
<asp:DataPoint AxisLabel="Lakers" YValues="15" />
<asp:DataPoint AxisLabel="Bulls" YValues="6" />
<asp:DataPoint AxisLabel="Spurs" YValues="4" />
<asp:DataPoint AxisLabel="76ers" YValues="3" />
<asp:DataPoint AxisLabel="Pistons" YValues="3" />
<asp:DataPoint AxisLabel="Warriors" YValues="3" />
<asp:DataPoint AxisLabel="Mara" YValues="4" />
<asp:DataPoint AxisLabel="Saza" YValues="9" />
<asp:DataPoint AxisLabel="Buha" YValues="6" />
</Points>
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="MainChartArea">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>
With only 9 bars it works, but I don't know why it fails with more than 9 bars. Is there any way to make the chart work properly? Also, if possible, how to make each bar have different color?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我遇到了同样的问题,但我在页面加载时使用 C# 。
我通过添加这个解决了这个问题
I had the same problem, but i'm using c# on page load.
I solved it by adding this
Chart2.ChartAreas["ChartArea1"].AxisX.Interval = 1;
Chart2.ChartAreas["ChartArea1"].AxisX.Interval = 1;
尝试设置图表的宽度,看看是否可以解决仅显示 9 个条形的问题。
您可以在 DataPoint 中设置颜色。
Try setting the width of the chart and see if that resolves issue with only showing 9 bars.
You can set the color in the DataPoint.