开发者

Microsoft Chart control in WinForms app - how to display a composite chart

开发者 https://www.devze.com 2023-03-12 19:05 出处:网络
I need to display a chart showing per-month sales; I want to display the volume as one column and the sales as a different column (both in each month). The problem, however, is that I have multiple sa

I need to display a chart showing per-month sales; I want to display the volume as one column and the sales as a different column (both in each month). The problem, however, is that I have multiple sales values for each month, one per currency. I wanted this to be a stacked column, showing the different values one on top of the other.

My problem is that when I make the second series stacked column, 开发者_如何学Pythonit stacks it on top of the first value. I don't want that. Can someone explain how to configure this correctly?

Example data:

  • Jan 2011: qty 30, sales: 10 USD, 15 GBP, 0 EUR
  • Feb 2011: qty 40, sales: 20 USD, 5 GBP, 5 EUR
  • Mar 2011: qty 80, sales: 30 USD, 10 GBP, 10 EUR

I am using the default chart control in Visual Studio 2010. This is a WinForms application, not web.


Use the StackedGroupName custom property.

To place multiple series in the same stacked group, assign the same name to them.

To show multiple stacks, assign different names to multiple series.

From the samples project:

// Set the first two series to be grouped into Group1
chart1.Series["LightBlue"]["StackedGroupName"] = "Group1";
chart1.Series["Gold"]["StackedGroupName"] = "Group1";

// Set the last two series to be grouped into Group2
chart1.Series["Red"]["StackedGroupName"] = "Group2";
chart1.Series["DarkBlue"]["StackedGroupName"] = "Group2";
0

精彩评论

暂无评论...
验证码 换一张
取 消