Jump to content
Software FX Community

Problem with Bar/Area


kennfarbe
 Share

Recommended Posts

Hi!I have a problem with my chart. If I add a serie with an area, the serie with the bar is now from top to bottom and not from bottom to top. What can I do that the bar will be display again as normal from the botten to top?

Here my example-code:

  Chart Chart2 = new Chart();   List<object> allArrays = new List<object>();   allArrays.Add(new double[] { 446, 113, 7, 344 });   allArrays.Add(new double[] { 2, 4, 7, 12 });   allArrays.Add(new double[] { 100, 45, 1, 44 });   allArrays.Add(new double[] { 546, 213, 12, 444 });   allArrays.Add(new double[] { 2, 4, 7, 12 });   AxisY y0 = Chart2.Panes[0].Axes[0];   AxisY y1 = new AxisY();   Chart2.Panes[0].Axes.Add(y1);   Chart2.Series.Add(new SeriesAttributes());   Chart2.Series.Add(new SeriesAttributes());   Chart2.Series[0].AxisY = y0;   Chart2.Series[1].AxisY = y1;   Chart2.Series[0].Pane = Chart2.Panes[0];   Chart2.Series[1].Pane = Chart2.Panes[0];   Chart2.Series[0].Text = "Series 0";   Chart2.Series[1].Text = "Series 1";   Chart2.Series[0].Gallery = Gallery.Bar;   Chart2.Series[1].Gallery = Gallery.Area;   FieldMap fieldMap1 = new FieldMap();   fieldMap1.Name = "Field1";   fieldMap1.Usage = FieldUsage.Value;   FieldMap fieldMap2 = new FieldMap();   fieldMap2.Name = "Field2";   fieldMap2.Usage = FieldUsage.XValue;   FieldMap fieldMap3 = new FieldMap();   fieldMap3.Name = "Field3";   fieldMap3.Usage = FieldUsage.FromValue;   FieldMap fieldMap4 = new FieldMap();   fieldMap4.Name = "Field4";   fieldMap4.Usage = FieldUsage.Value;   FieldMap fieldMap5 = new FieldMap();   fieldMap5.Name = "Field5";   fieldMap5.Usage = FieldUsage.XValue;

  Chart2.DataSourceSettings.Fields.Clear();   Chart2.DataSourceSettings.Fields.Add(fieldMap1);   Chart2.DataSourceSettings.Fields.Add(fieldMap2);   Chart2.DataSourceSettings.Fields.Add(fieldMap3);   Chart2.DataSourceSettings.Fields.Add(fieldMap4);   Chart2.DataSourceSettings.Fields.Add(fieldMap5);   ListProvider DataProvider = new ListProvider(allArrays);   Chart2.DataSource = DataProvider;   StringWriter sw = new StringWriter();   HtmlTextWriter html = new HtmlTextWriter(sw);   Chart2.RenderControl(html);   Literal2.Text = sw.ToString();

Many thanks,

Thorsten

Link to comment
Share on other sites

There are two problems with this code:

1) If you supply Y-From, you need to do so for all series.

2) The Y-From values must precede the series' Value.

 So the code should look something like this (assuming you wanted the From values to be applied to the Area Series):

List<object> allArrays = new List<object>();

allArrays.Add(

new double[] { 446, 113, 7, 344 });allArrays.Add(new double[] { 2, 4, 7, 12 });

allArrays.Add(

new double[] { 100, 45, 1, 44 });allArrays.Add(new double[] { 546, 213, 12, 444 });

allArrays.Add(

new double[] { 2, 4, 7, 12 });allArrays.Add(new double[] { 0, 0, 0, 0 });

Chart1.AllSeries.Gallery =

Gallery.Bar;AxisY y0 = Chart1.Panes[0].Axes[0];AxisY y1 = new AxisY();

Chart1.Panes[0].Axes.Add(y1);

Chart1.Series.Add(

new SeriesAttributes());Chart1.Series.Add(new SeriesAttributes());

Chart1.Series[0].AxisY = y0;

Chart1.Series[1].AxisY = y1;

Chart1.Series[0].Pane = Chart1.Panes[0];

Chart1.Series[1].Pane = Chart1.Panes[0];

Chart1.Series[0].Text =
"Bar";

Chart1.Series[1].Text =

"Area";Chart1.Series[0].Gallery = Gallery.Bar;

Chart1.Series[1].Gallery =

Gallery.Area;FieldMap fieldMap1 = new FieldMap();

fieldMap1.Name =

"Field1";fieldMap1.Usage = FieldUsage.Value;

FieldMap fieldMap2 = new FieldMap();fieldMap2.Name = "Field2";

fieldMap2.Usage =

FieldUsage.XValue;FieldMap fieldMap3 = new FieldMap();

fieldMap3.Name =

"Field3";fieldMap3.Usage = FieldUsage.FromValue;

FieldMap fieldMap4 = new FieldMap();fieldMap4.Name = "Field4";

fieldMap4.Usage =

FieldUsage.Value;FieldMap fieldMap5 = new FieldMap();

fieldMap5.Name =

"Field5";fieldMap5.Usage = FieldUsage.XValue;

FieldMap fieldMap6 = new FieldMap();fieldMap6.Name = "Field6";fieldMap6.Usage = FieldUsage.FromValue;

Chart1.DataSourceSettings.Fields.Clear();

Chart1.DataSourceSettings.Fields.Add(fieldMap6);  // From values for first series (Bar)

Chart1.DataSourceSettings.Fields.Add(fieldMap1);

Chart1.DataSourceSettings.Fields.Add(fieldMap2);

Chart1.DataSourceSettings.Fields.Add(fieldMap3);  // From values for second series (Area)

Chart1.DataSourceSettings.Fields.Add(fieldMap4);

Chart1.DataSourceSettings.Fields.Add(fieldMap5);

ListProvider DataProvider = new ListProvider(allArrays);

Chart1.DataSource = DataProvider;

Code.txt

Link to comment
Share on other sites

There are two problems with this code:

1) If you supply Y-From, you need to do so for all series.

2) The Y-From values must precede the series' Value.

 So the code should look something like this (assuming you wanted the From values to be applied to the Area Series):

List<object> allArrays = new List<object>();

allArrays.Add(

new double[] { 446, 113, 7, 344 });allArrays.Add(new double[] { 2, 4, 7, 12 });

allArrays.Add(

new double[] { 100, 45, 1, 44 });allArrays.Add(new double[] { 546, 213, 12, 444 });

allArrays.Add(

new double[] { 2, 4, 7, 12 });allArrays.Add(new double[] { 0, 0, 0, 0 });

Chart1.AllSeries.Gallery =

Gallery.Bar;AxisY y0 = Chart1.Panes[0].Axes[0];AxisY y1 = new AxisY();

Chart1.Panes[0].Axes.Add(y1);

Chart1.Series.Add(

new SeriesAttributes());Chart1.Series.Add(new SeriesAttributes());

Chart1.Series[0].AxisY = y0;

Chart1.Series[1].AxisY = y1;

Chart1.Series[0].Pane = Chart1.Panes[0];

Chart1.Series[1].Pane = Chart1.Panes[0];

Chart1.Series[0].Text =
"Bar";

Chart1.Series[1].Text =

"Area";Chart1.Series[0].Gallery = Gallery.Bar;

Chart1.Series[1].Gallery =

Gallery.Area;FieldMap fieldMap1 = new FieldMap();

fieldMap1.Name =

"Field1";fieldMap1.Usage = FieldUsage.Value;

FieldMap fieldMap2 = new FieldMap();fieldMap2.Name = "Field2";

fieldMap2.Usage =

FieldUsage.XValue;FieldMap fieldMap3 = new FieldMap();

fieldMap3.Name =

"Field3";fieldMap3.Usage = FieldUsage.FromValue;

FieldMap fieldMap4 = new FieldMap();fieldMap4.Name = "Field4";

fieldMap4.Usage =

FieldUsage.Value;FieldMap fieldMap5 = new FieldMap();

fieldMap5.Name =

"Field5";fieldMap5.Usage = FieldUsage.XValue;

FieldMap fieldMap6 = new FieldMap();fieldMap6.Name = "Field6";fieldMap6.Usage = FieldUsage.FromValue;

Chart1.DataSourceSettings.Fields.Clear();

Chart1.DataSourceSettings.Fields.Add(fieldMap6);  // From values for first series (Bar)

Chart1.DataSourceSettings.Fields.Add(fieldMap1);

Chart1.DataSourceSettings.Fields.Add(fieldMap2);

Chart1.DataSourceSettings.Fields.Add(fieldMap3);  // From values for second series (Area)

Chart1.DataSourceSettings.Fields.Add(fieldMap4);

Chart1.DataSourceSettings.Fields.Add(fieldMap5);

ListProvider DataProvider = new ListProvider(allArrays);

Chart1.DataSource = DataProvider;

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...