Jan
100
120
20.00%
Feb
130
-23.08%
Mar
160
70
-56.25%
Apr
200
-50.00%
May
180
140
-22.22%
Jun
170
190
11.76%
I have got the datas Month in the X- axis and Sales1 and Sales2 as the bar columns. I also need to have the growth marked on the graph. The growth values should be marked on the right Y-axis along with the growth points connected in the graph. I am using the following code which gives me a partial result.
Cmd = new SqlCommand (Procedure, Conn);
Reader = Cmd.ExecuteReader();
DT =
new DataTable();
DT.Columns.Add(
"Month", typeof(System.String));
"Sales1", typeof(System.Int32));
"Sales2", typeof(System.Int32));
"Percentage", typeof(System.String));
while(Reader.Read())
{
DT.Rows.Add(
new object[] { Reader.GetSqlValue(0), Reader.GetValue(1), Reader.GetValue(2), Reader.GetSqlValue(3) });
}
Reader.Close();
ultraChart1.Axis.Y.RangeType = Infragistics.UltraChart.Shared.Styles.
AxisRangeType.Custom;
ultraChart1.Axis.Y.RangeMin = 0;
ultraChart1.Axis.Y.RangeMax = 200;
ultraChart1.Axis.Y2.Visible =
true;
ultraChart1.Axis.Y2.LineDrawStyle = Infragistics.UltraChart.Shared.Styles.
LineDrawStyle.Solid;
ultraChart1.Axis.Y2.LineColor =
Color.White;
//ultraChart1.Axis.Y2.RangeType = Infragistics.UltraChart.Shared.Styles.AxisRangeType.Custom;
//ultraChart1.Axis.Y2.RangeMin = -70.00;
//ultraChart1.Axis.Y.RangeMax = 30.00;
//ultraChart1.Axis.Y2.TickmarkInterval = 10;
ultraChart1.DataSource = DT;
ultraChart1.Data.DataBind();
Any suggesstions?
Thanks & Regards
Ferdin
For BarChart, I think the best way to show the data you have, would be to group them on Y axis. Try the following code and see it addresses your scenario.
private void Form1_Load(object sender, EventArgs e) { ultraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.BarChart; ultraChart1.DataSource = GetData(); ultraChart1.Data.DataBind();
ultraChart1.Axis.Y.Labels.SeriesLabels.Orientation = Infragistics.UltraChart.Shared.Styles.TextOrientation.Custom; ultraChart1.Axis.Y.Labels.SeriesLabels.OrientationAngle = 45;
ChartTextAppearance growthText = new ChartTextAppearance(); growthText.Column = 0; growthText.Row = -2; growthText.VerticalAlign = StringAlignment.Center; growthText.HorizontalAlign = StringAlignment.Near; growthText.ItemFormatString = "<DATA_VALUE>%"; growthText.Visible = true; growthText.FontColor = Color.Black; ultraChart1.BarChart.ChartText.Add(growthText);
ChartTextAppearance salesText1 = new ChartTextAppearance(); salesText1.Column = 2; salesText1.Row = -2; salesText1.VerticalAlign = StringAlignment.Center; salesText1.HorizontalAlign = StringAlignment.Near; salesText1.ItemFormatString = "<DATA_VALUE>"; salesText1.Visible = true; salesText1.FontColor = Color.White; ultraChart1.BarChart.ChartText.Add(salesText1);
ChartTextAppearance salesText2 = new ChartTextAppearance(); salesText2.Column = 1; salesText2.Row = -2; salesText2.VerticalAlign = StringAlignment.Center; salesText2.HorizontalAlign = StringAlignment.Near; salesText2.ItemFormatString = "<DATA_VALUE>"; salesText2.Visible = true; salesText2.FontColor = Color.White; ultraChart1.BarChart.ChartText.Add(salesText2); }
private DataTable GetData() { DataTable mydata = new DataTable(); mydata.Columns.Add("Series Labels", typeof(string)); mydata.Columns.Add("Growth", typeof(double)); mydata.Columns.Add("Sales2", typeof(int)); mydata.Columns.Add("Sales1", typeof(int)); mydata.Rows.Add(new Object[] { "Jan", 20.00, 120, 100 }); mydata.Rows.Add(new Object[] { "Feb", -23.08, 100, 130 }); mydata.Rows.Add(new Object[] { "Mar", -56.25, 70, 160 }); mydata.Rows.Add(new Object[] { "Apr", -50.00, 100, 200 }); mydata.Rows.Add(new Object[] { "May", -22.22, 140, 180 }); mydata.Rows.Add(new Object[] { "Jun", 11.76, 190, 170 }); return mydata; }
Hi Sam,
Thanks for the reply i am sorry i made a mistake i'm not looking for the bar chart, i am looking for the column chart in which the Sales1, Sales2 of Month should be displayed and the growth of Month should be marked on the same chart as points and the points connected to each other. Is there any way to achieve this?
Thanks in advance
Prabhakaran
I have changed it to a ColumnChart. Is this any close to what you are looking for?
In order to format the appearance of the data value, such as font size or color, you can use FillScenegraph event to do get reference of the primitive and customize it. For more information please refer to the following help topic:
http://help.infragistics.com/Help/NetAdvantage/WinForms/2009.1/CLR2.0/html/Chart_FillSceneGraph_Event.html
Hi, I iterated dinamically throught all columns and added the ChartTextAppearance for every column. Now I want to format values, in the same way, for the following chart types, but there is not the .ChartText.Add() method!
BarChart3DCylinderBarChart3DCylinderColumnChart3DLineChartLineChart3D
Which property/method must I use in this case?
I forget to tell you that I want to format all bars at the same time, not only one.
Thanks.
I want to format bars in the same way you do int this example. Could you post your code here? Thanks in advance!
Sam,
Thank you for the support which you gave me.
Sam atlast i got the chart as expected using the Composite chart which includes Column Chart as first layer and Scatter Chart as the Second layer.
Once again i thank you for the support.
Thanks