Jump to content
Software FX Community

Two kinds of charts : Range column and grouped column ?


julien.nicolas1

Recommended Posts

- Grouped Column Chart

chart1.Data.Series = 4;chart1.Data.Points = 10;Random r = new Random();

Random r = new Random();

for (int i = 0; i < 4; i++) {   for (int j = 0; j < 10; j++) {   chart1.Data[i, j] = r.NextDouble() * 20;   }}

chart1.Gallery = Gallery.Bar;chart1.Series[1].Stacked = true;chart1.Series[2].Stacked = false;chart1.Series[3].Stacked = true;

chart1.Gallery = Gallery.Bar;chart1.Series[1].Stacked = true;chart1.Series[2].Stacked = false;chart1.Series[3].Stacked = true;

The trick here is that to create the stacked groups you do not set the global stacked property but instead create set the stacked property on a per-series basis. Note that we set it to false on the third series which actually "creates" a new stacked group. The value for Series[0].Stacked is not used.

- Range Column Chart

chart1.Data.Series = 2;chart1.Data.Points = 10;

Random r = new Random();for (int i = 0; i < 2; i++) {   for (int j = 0; j < 10; j++) {   double from = r.NextDouble() * 30;   chart1.Data.YFrom[i, j] = from;   chart1.Data[i, j] = from + (r.NextDouble() * 50);   }}

chart1.Gallery = Gallery.Bar;

Random r = new Random();for (int i = 0; i < 2; i++) {   for (int j = 0; j < 10; j++) {   double from = r.NextDouble() * 30;   chart1.Data.YFrom[i, j] = from;   chart1.Data[i, j] = from + (r.NextDouble() * 50);   }}

chart1.Gallery = Gallery.Bar;

Gallery.Bar;

In both cases I am setting some random data but the code would be similar if you are binding the chart to a database, XML, etc. When databinding you may need to use the DataSourceSettings property to create a FieldMap with FieldUsage.FromValue to achieve the RangeColumn chart.

JuanC

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...