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 = { const chartconfig = {
chart: { chart: {
animation: {
duration: 500
},
marginRight: 50 marginRight: 50
}, },
title: { title: {
@@ -513,9 +510,10 @@
enabled: false enabled: false
}, },
xAxis: { xAxis: {
type: "category" type: 'category'
}, },
yAxis: { yAxis: {
//min: 0,
opposite: true, opposite: true,
tickPixelInterval: 150, tickPixelInterval: 150,
title: { title: {
@@ -524,17 +522,17 @@
stackLabels: { stackLabels: {
enabled: true, enabled: true,
formatter: function () { formatter: function () {
return Highcharts.numberFormat(this.total, null, null, ','); return Highcharts.numberFormat(this.total, 2, null, ',');
} }
}, },
labels: { // labels: {
style: { // style: {
color: 'red' // color: 'red'
}, // },
formatter: function () { // formatter: function () {
return Highcharts.numberFormat(this.value, null, null, ','); // return Highcharts.numberFormat(this.value, null, null, ',');
} // }
} // }
}, },
//tooltip: { //tooltip: {
// formatter: function (tooltip) { // formatter: function (tooltip) {
@@ -551,19 +549,19 @@
//}, //},
plotOptions: { plotOptions: {
series: { series: {
animation: false, animation: true,
groupPadding: 0, groupPadding: 0,
pointPadding: 0.1, pointPadding: 0.1,
borderWidth: 0, borderWidth: 0,
colorByPoint: true, colorByPoint: true,
//dataSorting: { //dataSorting: {
// enabled: false, // enabled: true,
// matchByName: true // matchByName: true
//}, //},
stacking: 'normal', stacking: 'normal',
type: "bar", type: 'bar',
dataLabels: { dataLabels: {
enabled: true, enabled: false,
// format: '${y}' // format: '${y}'
// formatter: function () { // formatter: function () {
// var defaultlabel = Highcharts.getOptions().plotOptions[this.point.series.type].dataLabels.formatter.call(this); // var defaultlabel = Highcharts.getOptions().plotOptions[this.point.series.type].dataLabels.formatter.call(this);
@@ -573,6 +571,14 @@
// formatter: function () { // formatter: function () {
// return this.total; // 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 //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_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_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_compacreed").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CompAcreed"]) }] })
$('#' + "chartdiv_cxp192").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxP192"]) }] }) //$('#' + "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_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_cxc").highcharts({ ...chartconfig, series: [{ ...chartconfig.series[0], data: customAccessor(json["CxC"]) }, { type: 'line', data: customAccessor(json["CxCR"]) }] })
function customAccessor(data) { function customAccessor(data) {
const newData = []; const newData = [];
@@ -603,6 +609,10 @@
newData.push([point.Texto, point.Valor, point.Unidad]); 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; 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 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 { 'Dim group_vxp = vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {
' .Texto = Function(x) x.Texto.ToString, ' .Texto = g.Key,
' .Valor = Math.Round(Function(x) x.Valor, 2), ' .Valor = Math.Round(g.Sum(Function(x) x.Valor), 2),
' .Unidad = "MXN" ' .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 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 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 { Dim group_resto_vxp = resto_vxp.GroupBy(Function(x) x.Texto).[Select](Function(g) New With {