如何在 ASP.NET 中创建 StackedColumn 图表?
我有一个数据集,希望使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
堆叠图表不需要多个系列吗?我相信你需要为你想要的东西创建三个。
Don't you need more than one Series for a stacked chart? I believe you need to create three for what you want.
看一下:
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();