如何在 ASP.NET 中创建 StackedColumn 图表?

发布于 2024-10-10 03:56:38 字数 1895 浏览 3 评论 0原文

我有一个数据集,希望使用 VS 2010 中的内置图表将其呈现为堆叠柱形图。数据如下所示,并通过存储过程从 SQL Server 返回:

numTrades   Type    symbol
3   BreakEven   GBPCHF
7   Loss    GBPCHF
11  Win GBPCHF
1   BreakEven   GBPJPY
3   Loss    GBPJPY
7   Win GBPJPY
7   Loss    GBPUSD
13  Win GBPUSD

我用于呈现图表的 ASP.Net 代码如下这个:

<asp:Chart 
    ID="chtWinnerPercentagePie" 
    runat="server" 
    DataMember="DefaultView" 
    Height="600px" 
    Palette="Pastel" 
    Width="900px"  
    AlternateText="WinLoss Pie" 
    SkinID="chartSkin"
    ImageType="Png" >
   <Series >
      <asp:Series 
        Name="WinnersLosers" 
        ChartType="StackedColumn"
        ChartArea="MainChartArea" 
        XValueMember="symbol" 
        YValueMembers="numTrades">             
      </asp:Series>          
   </Series>       
   <Legends>
    <asp:Legend Name="Legend" ForeColor="#A1A5A9" BackColor="#161616" />
   </Legends>
   <ChartAreas>       
      <asp:ChartArea 
        Name="MainChartArea" 
        BackColor="#2C2C2C">
        <AxisY Title="Num Trades" TitleForeColor="White"> 
            <LabelStyle ForeColor="White" />                   
            <MajorGrid LineColor="#000000" />
        </AxisY>
        <AxisX Enabled="True">
            <LabelStyle ForeColor="White" />
        </AxisX>
      </asp:ChartArea>
   </ChartAreas>
    <Titles>
        <asp:Title 
            Name="ChartTitle" 
            Text="Win/Loss Ratio" 
            Font="Microsoft Sans Serif, 10pt" 
            ForeColor="#A1A5A9" 
            BackColor="#161616">
        </asp:Title>
    </Titles>
</asp:Chart> 

我没有得到堆积图表,而是在加载页面时得到这个: http://tinypic.com/r/66kljl/7

我哪里出错了?

I have a dataset that I want rendered as a stacked column chart using the built-in charting in VS 2010. The data looks like this and is returned from SQL Server from a stored procedure:

numTrades   Type    symbol
3   BreakEven   GBPCHF
7   Loss    GBPCHF
11  Win GBPCHF
1   BreakEven   GBPJPY
3   Loss    GBPJPY
7   Win GBPJPY
7   Loss    GBPUSD
13  Win GBPUSD

My ASP.Net code for rendering the chart looks like this:

<asp:Chart 
    ID="chtWinnerPercentagePie" 
    runat="server" 
    DataMember="DefaultView" 
    Height="600px" 
    Palette="Pastel" 
    Width="900px"  
    AlternateText="WinLoss Pie" 
    SkinID="chartSkin"
    ImageType="Png" >
   <Series >
      <asp:Series 
        Name="WinnersLosers" 
        ChartType="StackedColumn"
        ChartArea="MainChartArea" 
        XValueMember="symbol" 
        YValueMembers="numTrades">             
      </asp:Series>          
   </Series>       
   <Legends>
    <asp:Legend Name="Legend" ForeColor="#A1A5A9" BackColor="#161616" />
   </Legends>
   <ChartAreas>       
      <asp:ChartArea 
        Name="MainChartArea" 
        BackColor="#2C2C2C">
        <AxisY Title="Num Trades" TitleForeColor="White"> 
            <LabelStyle ForeColor="White" />                   
            <MajorGrid LineColor="#000000" />
        </AxisY>
        <AxisX Enabled="True">
            <LabelStyle ForeColor="White" />
        </AxisX>
      </asp:ChartArea>
   </ChartAreas>
    <Titles>
        <asp:Title 
            Name="ChartTitle" 
            Text="Win/Loss Ratio" 
            Font="Microsoft Sans Serif, 10pt" 
            ForeColor="#A1A5A9" 
            BackColor="#161616">
        </asp:Title>
    </Titles>
</asp:Chart> 

I am not getting a stacked chart, I get this instead when I load the page:
http://tinypic.com/r/66kljl/7

Where am I going wrong?

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

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

发布评论

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

评论(2

萌能量女王 2024-10-17 03:56:38

堆叠图表不需要多个系列吗?我相信你需要为你想要的东西创建三个。

Don't you need more than one Series for a stacked chart? I believe you need to create three for what you want.

蓝礼 2024-10-17 03:56:38

看一下:

http: //liberofusioncharts.codeplex.com/wikipage?title=Single%20Series%20Chart,%20adding%20data%20manually&referringTitle=Home

只需要更改 c# 代码中的第一行:

from: Column3DChart oChart =新的 Column3DChart();

至:StackedBar2DChart oChart = new StackedBar2DChart();

在此处输入图像描述

Take a look at:

http://liberofusioncharts.codeplex.com/wikipage?title=Single%20Series%20Chart,%20adding%20data%20manually&referringTitle=Home

Just need to change the line 1st line in the c# code:

from: Column3DChart oChart = new Column3DChart();

to : StackedBar2DChart oChart = new StackedBar2DChart();

enter image description here

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