Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
640
UltraWinChart Y axis problem
posted
Hi
 
I am working on a barchart with the following data
 
   Month           Sales1    Sales2          Growth

Jan

100

120

20.00%

Feb

130

100

-23.08%

Mar

160

70

-56.25%

Apr

200

100

-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));

DT.Columns.Add(

"Sales1", typeof(System.Int32));

DT.Columns.Add(

"Sales2", typeof(System.Int32));

DT.Columns.Add(

"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

Parents
No Data
Reply
  • 7305
    Verified Answer
    posted

    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;
            } 

Children