locked
How to manually set x and y axis for ajax LineChart RRS feed

  • Question

  • User1344924657 posted

    I have some line charts where I want to set the Y axis to min = 0 and max = 100. Here is my code below. Currently depending on what data is pull back the chart ranges from max 80 to 100 instead of a consistent 100.

    <cc1:LineChart ID="LCCallCenterWeeklyComparison" runat="server" EnableViewState="True" ImageStorageMode="UseImageLocation"
                                                            BaseLineColor="#A156AB" CategoryAxisLineColor="#D08AD9" ChartHeight="300"
                                                            ChartTitleColor="#0E426C" ChartType="Basic" ChartWidth="400"
                                                            ValueAxisLineColor="#D08AD9" Visible="false">
                                                        </cc1:LineChart>

     void loadcallcenterweeklycomparisonchart()
      {
          DateTime stdt = DateTime.Now.AddDays(-21);
          DateTime eddt = DateTime.Now;
          string query = string.Format("SELECT DATEADD(dd, 7-(DATEPART(dw, min(Start_Date))), min(Start_Date)) as EndOfWeek, " +
             "'Compliance %' = CONVERT(decimal(5,0), 100* SUM([TotaliCareTransfers&Conferences]) / SUM([TotalConferenceAndTransfers])) " +
         "FROM [VoipReporting].[dbo].[Softphone_Compliance] " +
         "WHERE " +
             "Start_Date Between '" + stdt + "' and '" + eddt.AddDays(+1) + "' " +
             "and CALL_CENTER = '" + ddlcallcenters.SelectedItem.Text + "' " +
         "GROUP BY datepart(week,Start_Date) ORDER BY datepart(week,Start_Date)");
          DataTable dt = GetData(query);

          string[] x = new string[dt.Rows.Count];
          decimal[] y = new decimal[dt.Rows.Count];
          for (int i = 0; i < dt.Rows.Count; i++)
          {
              x[i] = Convert.ToDateTime(dt.Rows[i][0]).ToShortDateString();
              y[i] = Convert.ToInt32(dt.Rows[i][1]);
          }
          LCCallCenterWeeklyComparison.Series.Add(new AjaxControlToolkit.LineChartSeries { Name = ddlcallcenters.SelectedItem.Text, Data = y, LineColor = "#000000" });
          LCCallCenterWeeklyComparison.CategoriesAxis = string.Join(",", x);
          LCCallCenterWeeklyComparison.ChartTitle = "Weekly Comparison";
          
          if (x.Length > 3)
          {
              LCCallCenterWeeklyComparison.ChartWidth = (x.Length * 75).ToString();
          }
          LCCallCenterWeeklyComparison.Visible = true;
      }

    Tuesday, August 2, 2016 4:27 PM

Answers

  • User61956409 posted

    Hi cgreene.gsu,

    I have some line charts where I want to set the Y axis to min = 0 and max = 100.

    Firstly, from documentation of LineChart control, we could not find any properties enables us to specify Y axis min&max value.

    Secondly, as far as I know, the Y axis could be changed via specify ValueAxisLines property.

    Besides, you give a feedback on this site.

    https://ajaxcontroltoolkit.codeplex.com/workitem/list/basic

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, August 4, 2016 10:26 AM