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?
Don't you need more than one Series for a stacked chart? I believe you need to create three for what you want.
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();
精彩评论