/// <summary> /// Construccion de graficos /// </summary> /// <param name="bars"></param> /// <param name="piramid"></param> public void buildGraph(int bars, int pie) { DataTable dt = (DataTable)Session[_nameSessionData]; DataTable dtLider = (DataTable)Session[_sesionListLider]; if (ddlVerPor.SelectedValue == "U") { pie = 2; } if (ddlLverPor.SelectedValue == "U") { bars = 2; } var sales = from p in dt.AsEnumerable() group p by p.Field <string>("Categoria") into g select new { category = g.Key, sales = g.Sum(p => p.Field <decimal>("Monto")) }; var Lider = from p in dtLider.AsEnumerable() group p by p.Field <string>("NombreLider") into g select new { category = g.Key, sales = g.Sum(p => p.Field <decimal>("porc")) }; sales.OrderByDescending(x => x.sales); if (bars == 2) { //foreach (var series in chartSales.Series) //{ // series.Points.Clear(); //} //chartSales.DataBind(); var Lider2 = from p in dtLider.AsEnumerable() group p by p.Field <string>("NombreLider") into g select new { category = g.Key, sales = g.Sum(p => p.Field <decimal>("Cantidadporc")) }; DataTable dtvew = new DataTable(); dtvew = DataUtil.toDataTable(Lider2.ToList()); chartSales.DataSource = Lider2; // Show as 2D or 3D if (CheckboxShow3D.Checked) { chartSales.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; } else { chartSales.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false; } chartSales.Series[0].ToolTip = "#LEGENDTEXT: #VAL{P0} - #PERCENT"; chartSales.ChartAreas[0].AxisY.LabelStyle.Format = "{#,##}%"; chartSales.Series[0].LegendToolTip = "#PERCENT"; chartSales.Series[0].LabelFormat = "{#,##}%"; chartSales.Series[0].IsValueShownAsLabel = true; // Set series members names for the X and Y values chartSales.Series[0].XValueType = System.Web.UI.DataVisualization.Charting.ChartValueType.String; chartSales.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "#.##"; chartSales.ChartAreas[0].AxisX.LabelStyle.Format = "0.00"; chartSales.ChartAreas[0].AxisX.LabelStyle.Format = "{0:0.00}"; // Set axis labels angle //chartSales.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = int.Parse(FontAngleList.SelectedItem.Text); chartSales.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = -40; // Set offset labels style chartSales.AntiAliasing = System.Web.UI.DataVisualization.Charting.AntiAliasingStyles.All; // Paint labels of all bars chartSales.ChartAreas[0].AxisX.Interval = 1; chartSales.DataBind(); } else if (bars > 0) { chartSales.DataSource = Lider; // Show as 2D or 3D if (CheckboxShow3D.Checked) { chartSales.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; } else { chartSales.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false; } chartSales.Series[0].ToolTip = "#LEGENDTEXT: #VAL{P0} - #PERCENT"; chartSales.ChartAreas[0].AxisY.LabelStyle.Format = "{#}%"; chartSales.Series[0].LegendToolTip = "#PERCENT"; chartSales.Series[0].LabelFormat = "{#}%"; chartSales.Series[0].IsValueShownAsLabel = true; // Set series members names for the X and Y values chartSales.Series[0].XValueType = System.Web.UI.DataVisualization.Charting.ChartValueType.String; // Set axis labels angle //chartSales.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = int.Parse(FontAngleList.SelectedItem.Text); chartSales.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = -40; // Set offset labels style chartSales.AntiAliasing = System.Web.UI.DataVisualization.Charting.AntiAliasingStyles.All; // Paint labels of all bars chartSales.ChartAreas[0].AxisX.Interval = 1; chartSales.DataBind(); } if (pie == 2) { var sales2 = from p in dt.AsEnumerable() group p by p.Field <string>("Categoria") into g select new { category = g.Key, sales = g.Sum(p => p.Field <int>("Cantidad")) }; // Set series and legend tooltips ChartPie.Series[0].ToolTip = "#LEGENDTEXT: #VAL"; ChartPie.Series[0].LegendToolTip = "Participación: #PERCENT - Unidades: #VAL";/// Label ="#PERCENT{P1}" ChartPie.Titles[0].Text = "Venta Global - Participación por categoría"; // Enlace de ods con el control de graficacion ChartPie.DataSource = sales2; ChartPie.DataBind(); // Set labels style ChartPie.Series[0]["PieLabelStyle"] = "outside"; // Enable 3D ChartPie.ChartAreas["Default"].Area3DStyle.Enable3D = chkShow3d.Checked; // Set chart type ChartPie.Series[0].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), comboBoxChartType.SelectedItem.Value.ToString(), true); if (this.comboBoxChartType.SelectedItem.Value.ToString() == "Doughnut") { ChartPie.Series[0]["DoughnutRadius"] = "20"; } } else if (pie > 0) { // Set series and legend tooltips ChartPie.Series[0].ToolTip = "#LEGENDTEXT: #VAL{C0}"; ChartPie.Series[0].LegendToolTip = "Participación: #PERCENT - Soles: #VAL{C0}";/// Label ="#PERCENT{P1}" ChartPie.Titles[0].Text = "Venta Global - Participación por categoría"; // Enlace de ods con el control de graficacion ChartPie.DataSource = sales; ChartPie.DataBind(); // Set labels style ChartPie.Series[0]["PieLabelStyle"] = "outside"; // Enable 3D ChartPie.ChartAreas["Default"].Area3DStyle.Enable3D = chkShow3d.Checked; // Set chart type ChartPie.Series[0].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), comboBoxChartType.SelectedItem.Value.ToString(), true); if (this.comboBoxChartType.SelectedItem.Value.ToString() == "Doughnut") { ChartPie.Series[0]["DoughnutRadius"] = "20"; } } }
/// <summary> /// Construccion de graficos /// </summary> /// <param name="bars"></param> /// <param name="piramid"></param> public void buildGraph(int bars, int pie) { DataTable dt = (DataTable)Session[_nameSessionData]; var sales = from p in dt.AsEnumerable() group p by p.Field <string>("mcv_description") into g select new { category = g.Key, sales = g.Sum(p => p.Field <decimal>("pventasneto")) }; sales.OrderByDescending(x => x.sales); if (bars > 0) { chartSales.DataSource = sales; // Show as 2D or 3D if (CheckboxShow3D.Checked) { chartSales.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true; } else { chartSales.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = false; } chartSales.Series[0].ToolTip = "#LEGENDTEXT: #VAL{C0} - #PERCENT"; chartSales.Series[0].LegendToolTip = "#PERCENT"; chartSales.Series[0].LabelFormat = "{C0}"; chartSales.Series[0].IsValueShownAsLabel = true; // Set series members names for the X and Y values chartSales.Series[0].XValueType = System.Web.UI.DataVisualization.Charting.ChartValueType.String; // Set axis labels angle chartSales.ChartAreas["ChartArea1"].AxisX.LabelStyle.Angle = int.Parse(FontAngleList.SelectedItem.Text); // Set offset labels style chartSales.AntiAliasing = System.Web.UI.DataVisualization.Charting.AntiAliasingStyles.All; // Paint labels of all bars chartSales.ChartAreas[0].AxisX.Interval = 1; chartSales.DataBind(); } if (pie > 0) { // Set series and legend tooltips ChartPie.Series[0].ToolTip = "#LEGENDTEXT: #VAL{C0}"; ChartPie.Series[0].LegendToolTip = "Participación: #PERCENT - Pesos: #VAL{C0}";///Label="#PERCENT{P1}" /// ChartPie.Titles[0].Text = "Venta Global - Participación por categoría"; // Enlace de ods con el control de graficacion ChartPie.DataSource = sales; ChartPie.DataBind(); // Set labels style ChartPie.Series[0]["PieLabelStyle"] = "outside"; // Enable 3D ChartPie.ChartAreas["Default"].Area3DStyle.Enable3D = chkShow3d.Checked; // Set chart type ChartPie.Series[0].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), comboBoxChartType.SelectedItem.Value.ToString(), true); if (this.comboBoxChartType.SelectedItem.Value.ToString() == "Doughnut") { ChartPie.Series[0]["DoughnutRadius"] = "20"; } } }