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