E172 Rep Indicadores intento 2 agrupar pesos y dolar en graficas

This commit is contained in:
MLopez
2022-12-13 20:05:32 -07:00
parent f01e47513d
commit f5b89dc3f4
2 changed files with 35 additions and 25 deletions

View File

@@ -500,9 +500,6 @@
const chartconfig = {
chart: {
animation: {
duration: 500
},
marginRight: 50
},
title: {
@@ -513,9 +510,10 @@
enabled: false
},
xAxis: {
type: "category"
type: 'category'
},
yAxis: {
//min: 0,
opposite: true,
tickPixelInterval: 150,
title: {
@@ -524,17 +522,17 @@
stackLabels: {
enabled: true,
formatter: function () {
return Highcharts.numberFormat(this.total, null, null, ',');
return Highcharts.numberFormat(this.total, 2, null, ',');
}
},
labels: {
style: {
color: 'red'
},
formatter: function () {
return Highcharts.numberFormat(this.value, null, null, ',');
}
}
// labels: {
// style: {
// color: 'red'
// },
// formatter: function () {
// return Highcharts.numberFormat(this.value, null, null, ',');
// }
// }
},
//tooltip: {
// formatter: function (tooltip) {
@@ -551,19 +549,19 @@
//},
plotOptions: {
series: {
animation: false,
animation: true,
groupPadding: 0,
pointPadding: 0.1,
borderWidth: 0,
colorByPoint: true,
//dataSorting: {
// enabled: false,
// enabled: true,
// matchByName: true
//},
stacking: 'normal',
type: "bar",
type: 'bar',
dataLabels: {
enabled: true,
enabled: false,
// format: '${y}'
// formatter: function () {
// var defaultlabel = Highcharts.getOptions().plotOptions[this.point.series.type].dataLabels.formatter.call(this);
@@ -573,6 +571,14 @@
// formatter: function () {
// return this.total;
// },
},
animation: {
duration: 750
}
},
pie: {
dataLabels: {
enabled: true
}
}
},
@@ -588,11 +594,11 @@
//AmCharts.makeChart("chartdiv_vxp", { ...chartconfig, type: "serial", dataProvider: json["VxP"] }); // Ventas x Producto
$('#' + "chartdiv_vxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["VxP"]) }] })
$('#' + "chartdiv_compproductores").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], type: 'pie', data: customAccessor(json["CompProductores"]) }] })
$('#' + "chartdiv_compacreed").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CompAcreed"]) }] })
$('#' + "chartdiv_cxp192").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP192"]) }] })
$('#' + "chartdiv_cxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP"]) }] })
$('#' + "chartdiv_cxc").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxC"]) }, { type: 'line', data: customAccessor(json["CxCR"]) }] })
//$('#' + "chartdiv_compproductores").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], type: 'pie', data: customAccessor(json["CompProductores"]) }] })
//$('#' + "chartdiv_compacreed").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CompAcreed"]) }] })
//$('#' + "chartdiv_cxp192").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP192"]) }] })
//$('#' + "chartdiv_cxp").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP"]) }] })
//$('#' + "chartdiv_cxc").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxC"]) }, { type: 'line', data: customAccessor(json["CxCR"]) }] })
function customAccessor(data) {
const newData = [];
@@ -603,6 +609,10 @@
newData.push([point.Texto, point.Valor, point.Unidad]);
}
});
//newData.sort(function (a, b) {
// return a[0] > b[0] ? 1 : -1;
//});
console.log(JSON.stringify(newData))
return newData;
}

View File

@@ -210,10 +210,10 @@ Partial Class General_RepIndicadorResumen
'Dim vxp = From s In DtVxP.AsEnumerable() Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
'Dim group_vxp = vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
' .Texto = Function(x) x.Texto.ToString,
' .Valor = Math.Round(Function(x) x.Valor, 2),
' .Texto = g.Key,
' .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2),
' .Unidad = "MXN"
'})
'}).ToDataTable
Dim top_vxp = From s In DtVxP.AsEnumerable().Take(10) Select New With {.Texto = s("Texto").ToString(), .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
Dim resto_vxp = From s In DtVxP.AsEnumerable().Skip(10) Select New With {.Texto = "Otros", .Valor = s("Valor").ToString().ToDouble(), .Unidad = s("Unidad").ToString()}
Dim group_resto_vxp = resto_vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {