I have the below stored procedure which I use to show data on multiple ASP chart items.
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetChartApprovedData`(in siteValue varchar(45),
in skillValue varchar(100), in shiftValue varchar(100), in tmValue varchar(45),
in grpmValue varchar(45), in dateValue date, in dateValue1 date)
BEGIN
SELECT count(agentlogin) AS totalApproved, shift AS Shift, skill AS Skill, tm AS TM, grpM AS GrpM
FROM approved
WHERE (sitevalue IS NULL
OR site = sitevalue)
AND (skillvalue IS NULL
OR skill = skillvalue)
AND (shiftvalue IS NULL
OR shift = shiftvalue)
AND (tmValue IS NULL
OR tm = tmValue)
AND (grpmValue IS NULL
OR grpM = grpmValue)
AND (dateValue IS NULL
OR date BETWEEN dateValue AND dateValue1)
group by shift, skill;
END
And when I use the above stored procedure to show the data in ASP chart I get the below result
Both the chart are giving the same grouping result. What I want is for the first chart I want it to group by shift and for the second chart I want it to be grouped by skill. Is it possible to achieve this without using separate stored procedure for both? Please let me know. Thanks in advance :)
private void GetChartData()
{
string MyConString = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
MySqlConnection con = new MySqlConnection(MyConString);
MySqlCommand cmd = new MySqlCommand("GetChartApprovedData");
cmd.CommandType = CommandType.StoredProcedure;
string siteValue = null;
DateTime? dateValue = null;
DateTime? dateValue1 = null;
if (ddlSite.SelectedValue != null && ddlSite.SelectedValue != "0")
{
siteValue = ddlSite.SelectedValue;
}
if (ViewState["Date"] != null && ViewState["Date"].ToString() != "0")
{
dateValue = DateTime.Parse(ViewState["Date"].ToString());
}
if (ViewState["Date1"] != null && ViewState["Date1"].ToString() != "0")
{
dateValue1 = DateTime.Parse(ViewState["Date1"].ToString());
}
cmd.Parameters.AddWithValue("siteValue", siteValue);
cmd.Parameters.AddWithValue("dateValue", dateValue);
cmd.Parameters.AddWithValue("dateValue1", dateValue1);
cmd.Connection = con;
con.Open();
MySqlDataReader myread = cmd.ExecuteReader();
while (myread.Read())
{
this.Chart2.Series["Series1"].Points.AddXY(myread["Shift"], myread["totalApproved"]);
Chart2.Series["Series1"].IsValueShownAsLabel = true;
Chart2.Series["Series1"].Label = "#VALY(#PERCENT)";
Chart2.Series["Series1"].ToolTip = "Shift: #VALX \\nCount: #VALY";
Chart2.ChartAreas["ChartArea1"].AxisX.LabelStyle.Interval = 1;
Chart2.Legends.Clear();
Chart2.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
Chart2.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
Chart2.Series["Series1"].Color = Color.DarkOrange;
this.Chart1.Series["Series1"].Points.AddXY(myread["Skill"], myread["totalApproved"]);
Chart1.Series["Series1"].IsValueShownAsLabel = true;
Chart1.Series["Series1"].Label = "#VALY(#PERCENT)";
Chart1.Series["Series1"].ToolTip = "Skill: #VALX \\nCount: #VALY";
Chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Interval = 1;
Chart1.Series["Series1"].Color = Color.DarkOrange;
Chart1.Series["Series1"].LabelBackColor = Color.White;
Chart1.Legends.Clear();
Chart1.ChartAreas["ChartArea1"].AxisX.MajorGrid.Enabled = false;
Chart1.ChartAreas["ChartArea1"].AxisY.MajorGrid.Enabled = false;
}
con.Close();
}
