2

我有一个数据集,我想使用 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

我哪里错了?

4

2 回答 2

1

看一眼:

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

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

来自:Column3DChart oChart = new Column3DChart();

到: StackedBar2DChart oChart = new StackedBar2DChart();

在此处输入图像描述

于 2011-01-08T02:17:15.760 回答
1

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

于 2011-01-04T15:18:21.610 回答