From 2c66e906e03929d447eb61c73e91a82e7f749bf5 Mon Sep 17 00:00:00 2001 From: MLopez Date: Thu, 8 Dec 2022 19:44:40 -0700 Subject: [PATCH] =?UTF-8?q?E172=20Rep=20Indicador=20gr=C3=A1fica=20barras?= =?UTF-8?q?=20ventas=20x=20productos=20top=2010=20y=20resto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- General/RepIndicadorResumen.aspx | 47 +++++++++++++++++++++++------ General/RepIndicadorResumen.aspx.vb | 20 +++++++++--- 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/General/RepIndicadorResumen.aspx b/General/RepIndicadorResumen.aspx index 831da99e6..fb5953c69 100644 --- a/General/RepIndicadorResumen.aspx +++ b/General/RepIndicadorResumen.aspx @@ -80,8 +80,9 @@ - -
SubProyecto
+
+ SubProyecto: +
@@ -434,7 +435,7 @@ // AmCharts.makeChart(chartdiv, chartconfig); // }); - AmCharts.makeChart("chartdiv_vxp", { ...chartconfig, dataProvider: json["VxP"] }); // Ventas x Producto + //AmCharts.makeChart("chartdiv_vxp", { ...chartconfig, type: "serial", dataProvider: json["VxP"] }); // Ventas x Producto AmCharts.makeChart("chartdiv_cxp", { ...chartconfig, dataProvider: json["CxP"] }); // Compras x Producto TipoProveedor 1 AmCharts.makeChart("chartdiv_cxp192", { ...chartconfig, dataProvider: json["CxP192"] }); // Compras x Producto ProveedorClasificacion 192 AmCharts.makeChart("chartdiv_ccxc", { ...chartconfig, dataProvider: json["CCxC"] }); // Cuentas por Cobrar x Cliente @@ -443,13 +444,14 @@ document.getElementById('amChartsAttribution').style.visibility = 'visible'; } - /* + function CargaGraficasBarras(json) { - var chart = AmCharts.makeChart("chartdiv2", { + var chart = AmCharts.makeChart("chartdiv_vxp", { + "hideCredits": true, "type": "serial", "theme": "light", - "dataProvider": json, + "dataProvider": json["VxP"], "startDuration": 2, "valueAxes": [{ "position": "left", @@ -472,14 +474,41 @@ }, "categoryField": "Texto", "categoryAxis": { - "gridPosition": "start", - "labelRotation": 90 + "labelsEnabled": false, + "forceShowField": false, + //"labelFunction": trimLabel + //"gridPosition": "start" + //"labelRotation": 90 }, "export": { "enabled": true } }); - }*/ + + var legend = new AmCharts.AmLegend(); + legend.fontSize = 9; + legend.labelWidth = 50; + legend.enabled = false; + + chart.addLegend(legend); + + chart.addListener('dataUpdated', function (e) { + var legendDataItems; //used to store the legend's custom data array. + + legendDataItems = e.chart.dataProvider.map(function (dataElement) { + return { + 'title': dataElement.Texto.length >= 7 ? dataElement.Texto.substr(0, 6) : dataElement.Texto, + 'color': dataElement.Color + } + }); + + // update the legend custom data and redraw the chart + e.chart.legend.data = legendDataItems; + e.chart.legend.enabled = true; + e.chart.validateNow(); + }); + + } diff --git a/General/RepIndicadorResumen.aspx.vb b/General/RepIndicadorResumen.aspx.vb index 624f51953..230c5c227 100644 --- a/General/RepIndicadorResumen.aspx.vb +++ b/General/RepIndicadorResumen.aspx.vb @@ -1,6 +1,7 @@ Imports System.Data Imports Extensiones Imports Microsoft.Reporting.WebForms +Imports MoreLinq Partial Class General_RepIndicadorResumen Inherits ClsPaginas @@ -136,9 +137,7 @@ Partial Class General_RepIndicadorResumen Private Sub CargaCombos() 'Carga SubProyectos - DdlSubProyecto.DataSource = GlobalDTSubProyectosUsuarios(UsuarioActual.CveUsuario, -1, UsuarioActual.CveEmpresa, -1, 1) - DdlSubProyecto.DataBind() - DdlSubProyecto.Items.Insert(0, New ListItem("Todos", "-1")) + CargarCentrosDeCosto(Nothing, DdlSubProyecto, Nothing, lblSubProyecto) TxtFechaI.Text = $"01/{Now.Month}/{Now.Year}" TxtFechaF.Text = Now.ToString("dd/MM/yyyy") @@ -243,6 +242,7 @@ Partial Class General_RepIndicadorResumen GvCxP192.DataBind() GvComprasAcreed.DataBind() GvCCxC.DataBind() + 'GvCCxC.HeaderRow.Cells(1).Text = "Saldo" GvCxP.DataBind() @@ -426,7 +426,18 @@ Partial Class General_RepIndicadorResumen End If End If Next - Dim query_vxp = From s In DtVxP.AsEnumerable().Take(20) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim top_vxp = From s In DtVxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim resto_vxp = From s In DtVxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Color = s("Color").ToString(), .Moneda = s("Moneda").ToString()} + Dim group_resto_vxp = resto_vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With { + .Texto = "Otros", + .Valor = g.Sum(Function(x) x.Valor), + .Color = "#000000", + .Moneda = "MXN" + }) + Dim query_vxp = top_vxp.Union(group_resto_vxp) + 'Dim query_vxp = top_vxp.Concat(From e In resto_vxp Group e By e.Texto Into gpo = Group) + 'Dim group_resto_vxp = From e In resto_vxp Group e By e.Texto Into gpo = Group + 'Dim group_resto_vxp = resto_vxp.GroupBy(Function(e) New With {Key e.Texto, Key e.Valor, Key e.Color, Key e.Moneda}).ToList() 'Compras x Producto TipoProveedor=1 DtCxP.Reset() @@ -533,6 +544,7 @@ Partial Class General_RepIndicadorResumen 'Dim json As String = Newtonsoft.Json.JsonConvert.SerializeObject(New With {.VxP = query_vxp, .CCxC = New String() {}}) 'Alert(json) RegistraScript($"CargaGraficasPastel({json})", "22") + RegistraScript($"CargaGraficasBarras({json})", "223") UPPMov.Update() End Sub Private Sub GraficasBarras()