E172 Rep Indicador gráfica barras ventas x productos top 10 y resto

This commit is contained in:
MLopez
2022-12-08 19:44:40 -07:00
parent 093320ebdb
commit 2c66e906e0
2 changed files with 54 additions and 13 deletions

View File

@@ -80,8 +80,9 @@
<ajax:MaskedEditExtender ID="MEEFechaF" runat="server" TargetControlID="TxtFechaF" Mask="99/99/9999" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"></ajax:MaskedEditExtender>
<ajax:CalendarExtender runat="server" ID="CalendarExtender1" TargetControlID="TxtFechaF" PopupButtonID="ImgFechaF" PopupPosition="BottomRight" Enabled="True"></ajax:CalendarExtender>
</div>
<div class="col-md-1 truncate" style="text-align: right!important; margin-left: 20px">SubProyecto</div>
<div class="col-md-1 truncate" style="text-align: right!important; margin-left: 20px">
<asp:Label runat="server" ID="lblSubProyecto">SubProyecto:</asp:Label>
</div>
<div class="col-md-1">
<asp:DropDownList ID="DdlSubProyecto" CssClass="form-control input-sm select2me" runat="server" Width="150px" DataTextField="SubProyecto" DataValueField="CveSubProyecto">
</asp:DropDownList>
@@ -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();
});
}
</script>
</asp:Content>

View File

@@ -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 = "<a href=""/CxC/RepCxC.aspx"" target=""_blank"">Saldo</a>"
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()