locked
Rotate axis X labels RRS feed

  • Question

  • User1310055179 posted

    Hi,

    I would like to know how to rotate a bit the labels in axis X in line chart or bar chart control?

    This is my code:

    <ajaxToolkit:LineChart ID="LineChart1" ChartHeight="300" ChartWidth = "450" runat="server" BaseLineColor="#A156AB" Visible="false"></ajaxToolkit:LineChart>
    
    string[] x = new string[graphDataSet.Tables[0].Rows.Count];
                            decimal[] y = new decimal[graphDataSet.Tables[0].Rows.Count];
                            for (int i = 0; i < graphDataSet.Tables[0].Rows.Count; i++)
                            {
                                x[i] = graphDataSet.Tables[0].Rows[i][0].ToString();
                                y[i] = Convert.ToInt32(graphDataSet.Tables[0].Rows[i][1]);
                            }
                            LineChart1.Series.Add(new AjaxControlToolkit.LineChartSeries { Data = y });
                            LineChart1.CategoriesAxis = string.Join(",", x);
     
                            if (x.Length > 3)
                            {
                                LineChart1.ChartWidth = (x.Length * 75).ToString();
                            }
     
                            LineChart1.Visible = true;

    Wednesday, January 3, 2018 12:54 PM

All replies

  • User-707554951 posted

    Hi qsoft_developer,

    For your problem, just adjust the axis data order before LineChart1.CategoriesAxis = string.Join(",", x).

    You could use Array.Reverse(x) to revereser original array

    If you still have problem, Would you please provide more details about what result you want to get so that I could provide code sample for you.

    https://www.aspsnippets.com/Articles/ASPNet-AJAX-Line-Chart-Control-Populate-from-Database-example.aspx

    Best regards 

    Cathy

    Thursday, January 4, 2018 9:45 AM
  • User1310055179 posted

    I would like to be able to show all text labels in the X index. 

    At the moment, since it is not rotated, the text overlapes one another, and cannot be read.

    Thursday, January 4, 2018 10:21 AM