ASP.NET 与 MS Chart 禁用垂直线

发布于 2024-08-24 22:31:30 字数 1225 浏览 3 评论 0原文

我有一个使用 MS Chart 创建的图表,如下图所示。正如您所看到的,垂直线与每个条形顶部的值混淆了。

替代文字 http://img46.imageshack.us/img46/3720/chartimgaxd.png

这是标记- 图表:

        <asp:Chart ID="chtNBAChampionships" runat="server">
   <Series>
      <asp:Series Name="Championships" YValueType="Int32"  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" />

         </Points>
      </asp:Series>
   </Series>
   <ChartAreas>
      <asp:ChartArea Name="MainChartArea">
      </asp:ChartArea>
   </ChartAreas>
</asp:Chart>

我不希望显示垂直线,因为它与每个条形顶部的值搞乱了。如何禁用垂直线?

谢谢。

I have a graph created with MS Chart like the following picture. As you can see the vertical lines are messed up with value of the top of each bar.

alt text http://img46.imageshack.us/img46/3720/chartimgaxd.png

Here's the mark-up for the graph:

        <asp:Chart ID="chtNBAChampionships" runat="server">
   <Series>
      <asp:Series Name="Championships" YValueType="Int32"  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" />

         </Points>
      </asp:Series>
   </Series>
   <ChartAreas>
      <asp:ChartArea Name="MainChartArea">
      </asp:ChartArea>
   </ChartAreas>
</asp:Chart>

I don't want the display the vertical line because it's messed up with the value on top of the each bar. How can I disable the vertical line?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

余厌 2024-08-31 22:31:30

简单的方法:

Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;

simple way:

Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
锦上情书 2024-08-31 22:31:30

我不知道具体的 ASP 语法,但这里有 VB.NET 代码,可以实现这一点:

Dim gd As New System.Windows.Forms.DataVisualization.Charting.Grid
gd.LineWidth = 0

myChart.ChartAreas("MainChartArea").AxisX.MajorGrid = gd

C# 版本(如果需要):

System.Web.UI.DataVisualization.Charting.Grid gd = new System.Web.UI.DataVisualization.Charting.Grid(); 
gd.LineWidth = 0; 

myChart.ChartAreas[0].AxisX.MajorGrid = gd;

如您所见,您不能只关闭网格线,您必须将其宽度设置为0. MinorGrid可以用同样的方式隐藏。

I don't know the specific ASP syntax, but here is the VB.NET code that does the trick:

Dim gd As New System.Windows.Forms.DataVisualization.Charting.Grid
gd.LineWidth = 0

myChart.ChartAreas("MainChartArea").AxisX.MajorGrid = gd

C# version if needed :

System.Web.UI.DataVisualization.Charting.Grid gd = new System.Web.UI.DataVisualization.Charting.Grid(); 
gd.LineWidth = 0; 

myChart.ChartAreas[0].AxisX.MajorGrid = gd;

As you can see, you can't just turn off the gridline, you have to set it's width to 0. The MinorGrid can be hidden the same way.

胡渣熟男 2024-08-31 22:31:30

最简单的方法,将以下代码放入图表加载事件中。

protected void Chart1_Load(object sender, EventArgs e)
{
    Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
    Chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;

}

Simplest way, put the following code in chart load event.

protected void Chart1_Load(object sender, EventArgs e)
{
    Chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
    Chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;

}
橘虞初梦 2024-08-31 22:31:30

这解决了这个问题。谢谢。

下面是c#代码......

var gd = new System.Web.UI.DataVisualization.Charting.Grid();
gd.LineWidth = 0;
Chart1.ChartAreas[0].AxisX.MajorGrid = gd;

This resolved the issue. Thanks.

Below is the c# code....

var gd = new System.Web.UI.DataVisualization.Charting.Grid();
gd.LineWidth = 0;
Chart1.ChartAreas[0].AxisX.MajorGrid = gd;
半窗疏影 2024-08-31 22:31:30

这可以从源头开始工作

<ChartAreas>
     <asp:ChartArea Name="ChartArea1">
         <AxisX>
              <MajorGrid LineWidth="0" />
         </AxisX>
     </asp:ChartArea>
</ChartAreas>

This could work from source

<ChartAreas>
     <asp:ChartArea Name="ChartArea1">
         <AxisX>
              <MajorGrid LineWidth="0" />
         </AxisX>
     </asp:ChartArea>
</ChartAreas>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文