@visionaris-bruno/vs-echarts 6.5.2 → 7.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { provideEchartsCore, NgxEchartsDirective } from 'ngx-echarts';
|
|
2
2
|
import * as echarts from 'echarts/core';
|
|
3
|
-
import { BarChart, PieChart, LineChart, ScatterChart, FunnelChart } from 'echarts/charts';
|
|
3
|
+
import { BarChart, PieChart, LineChart, ScatterChart, FunnelChart, SunburstChart } from 'echarts/charts';
|
|
4
4
|
import { TitleComponent, TooltipComponent, GridComponent, LegendComponent, GraphicComponent, ToolboxComponent, PolarComponent } from 'echarts/components';
|
|
5
5
|
import { CanvasRenderer, SVGRenderer } from 'echarts/renderers';
|
|
6
6
|
import * as i0 from '@angular/core';
|
|
@@ -65,6 +65,7 @@ function initializeEcharts() {
|
|
|
65
65
|
LineChart,
|
|
66
66
|
ScatterChart,
|
|
67
67
|
FunnelChart,
|
|
68
|
+
SunburstChart,
|
|
68
69
|
TitleComponent,
|
|
69
70
|
TooltipComponent,
|
|
70
71
|
GridComponent,
|
|
@@ -156,7 +157,10 @@ function defaultOptionsOverrides() {
|
|
|
156
157
|
},
|
|
157
158
|
funnel: {
|
|
158
159
|
series: {}
|
|
159
|
-
}
|
|
160
|
+
},
|
|
161
|
+
sunburst: {
|
|
162
|
+
series: {},
|
|
163
|
+
},
|
|
160
164
|
};
|
|
161
165
|
}
|
|
162
166
|
|
|
@@ -238,9 +242,18 @@ class BaseEchartsComponent {
|
|
|
238
242
|
*/
|
|
239
243
|
onInputChanges(changes) {
|
|
240
244
|
if (changes['data'] || changes['optionsOverrides'] || changes['palette'] || changes['colorResolver'] || changes['valueFormatter']) {
|
|
241
|
-
this.
|
|
245
|
+
this.prepareOptions();
|
|
242
246
|
}
|
|
243
247
|
}
|
|
248
|
+
prepareOptions() {
|
|
249
|
+
if (!this.chartInstance)
|
|
250
|
+
return;
|
|
251
|
+
if (!this.data)
|
|
252
|
+
return;
|
|
253
|
+
this.make();
|
|
254
|
+
const baseOptions = this.builder.getResult();
|
|
255
|
+
this.triggerUpdate(baseOptions);
|
|
256
|
+
}
|
|
244
257
|
/**
|
|
245
258
|
* Gatilla actualización.
|
|
246
259
|
*
|
|
@@ -254,7 +267,7 @@ class BaseEchartsComponent {
|
|
|
254
267
|
*/
|
|
255
268
|
onChartInit(instance) {
|
|
256
269
|
this.chartInstance = instance;
|
|
257
|
-
this.
|
|
270
|
+
this.prepareOptions();
|
|
258
271
|
}
|
|
259
272
|
onChartClick(event) {
|
|
260
273
|
if (event.componentType === 'series') {
|
|
@@ -393,7 +406,7 @@ function getLegendOptions(overrides) {
|
|
|
393
406
|
return merge({}, defaults, overrides);
|
|
394
407
|
}
|
|
395
408
|
function getCategoryAxisOptions(overrides) {
|
|
396
|
-
const categories = overrides?.data
|
|
409
|
+
const categories = resolveCategoryNames(overrides?.data);
|
|
397
410
|
const autoRotate = categories.length > 10 ? 45 : 0;
|
|
398
411
|
const defaults = {
|
|
399
412
|
type: 'category',
|
|
@@ -416,7 +429,7 @@ function getCategoryAxisOptions(overrides) {
|
|
|
416
429
|
}
|
|
417
430
|
}
|
|
418
431
|
};
|
|
419
|
-
return merge({}, defaults, overrides);
|
|
432
|
+
return merge({}, defaults, { ...overrides, data: categories });
|
|
420
433
|
}
|
|
421
434
|
function getValueAxisOptions(overrides) {
|
|
422
435
|
const defaults = {
|
|
@@ -582,26 +595,152 @@ function applyLineSelectionStyle(series, selectedCategoryIndex, selectedSeriesIn
|
|
|
582
595
|
};
|
|
583
596
|
});
|
|
584
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* Resolves the unique key of a category safely.
|
|
600
|
+
*/
|
|
601
|
+
function getCategoryKey(categories, index) {
|
|
602
|
+
if (!categories || !categories[index]) {
|
|
603
|
+
return String(index);
|
|
604
|
+
}
|
|
605
|
+
const node = categories[index];
|
|
606
|
+
return node.key || node.name || String(index);
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Resolves the numeric value from a series data point.
|
|
610
|
+
*/
|
|
611
|
+
function getCellValue(val) {
|
|
612
|
+
if (val === undefined || val === null)
|
|
613
|
+
return 0;
|
|
614
|
+
return val;
|
|
615
|
+
}
|
|
616
|
+
function flattenCategoriesToFirstLevel(categories) {
|
|
617
|
+
if (!categories)
|
|
618
|
+
return [];
|
|
619
|
+
return categories.map(cat => ({
|
|
620
|
+
name: cat.name,
|
|
621
|
+
key: cat.key
|
|
622
|
+
}));
|
|
623
|
+
}
|
|
624
|
+
function getLeafIndicesMap(categories) {
|
|
625
|
+
let leafCount = 0;
|
|
626
|
+
const topLevelLeaves = [];
|
|
627
|
+
const countLeaves = (node) => {
|
|
628
|
+
if (!node.children || node.children.length === 0) {
|
|
629
|
+
return 1;
|
|
630
|
+
}
|
|
631
|
+
let sum = 0;
|
|
632
|
+
for (const child of node.children) {
|
|
633
|
+
sum += countLeaves(child);
|
|
634
|
+
}
|
|
635
|
+
return sum;
|
|
636
|
+
};
|
|
637
|
+
for (const cat of categories) {
|
|
638
|
+
const leavesUnderCat = countLeaves(cat);
|
|
639
|
+
topLevelLeaves.push({
|
|
640
|
+
start: leafCount,
|
|
641
|
+
end: leafCount + leavesUnderCat
|
|
642
|
+
});
|
|
643
|
+
leafCount += leavesUnderCat;
|
|
644
|
+
}
|
|
645
|
+
return {
|
|
646
|
+
topLevelLeaves,
|
|
647
|
+
totalLeaves: leafCount
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
function collectLeafSeries(nodes, parentNamePath = []) {
|
|
651
|
+
const leaves = [];
|
|
652
|
+
for (const node of nodes) {
|
|
653
|
+
const currentPath = [...parentNamePath, node.name];
|
|
654
|
+
if (node.children && node.children.length > 0) {
|
|
655
|
+
leaves.push(...collectLeafSeries(node.children, currentPath));
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
const combinedName = currentPath.join(' ');
|
|
659
|
+
leaves.push({
|
|
660
|
+
...node,
|
|
661
|
+
name: combinedName
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
return leaves;
|
|
666
|
+
}
|
|
667
|
+
function flattenEChartData(data) {
|
|
668
|
+
if (!data)
|
|
669
|
+
return { categories: [], series: [] };
|
|
670
|
+
const categories = data.categories || [];
|
|
671
|
+
const series = data.series || [];
|
|
672
|
+
const topLevelCategories = flattenCategoriesToFirstLevel(categories);
|
|
673
|
+
const { topLevelLeaves } = getLeafIndicesMap(categories);
|
|
674
|
+
const flatSeries = collectLeafSeries(series).map(s => {
|
|
675
|
+
const aggregatedData = [];
|
|
676
|
+
for (const range of topLevelLeaves) {
|
|
677
|
+
let sum = 0;
|
|
678
|
+
for (let j = range.start; j < range.end; j++) {
|
|
679
|
+
sum += s.data[j] ?? 0;
|
|
680
|
+
}
|
|
681
|
+
aggregatedData.push(sum);
|
|
682
|
+
}
|
|
683
|
+
return {
|
|
684
|
+
...s,
|
|
685
|
+
data: aggregatedData
|
|
686
|
+
};
|
|
687
|
+
});
|
|
688
|
+
return {
|
|
689
|
+
categories: topLevelCategories,
|
|
690
|
+
series: flatSeries
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* Normalizes category nodes into an array of string names for category axes.
|
|
695
|
+
*/
|
|
696
|
+
function resolveCategoryNames(categories) {
|
|
697
|
+
if (!categories)
|
|
698
|
+
return [];
|
|
699
|
+
return categories.map(c => {
|
|
700
|
+
if (!c)
|
|
701
|
+
return '';
|
|
702
|
+
if (typeof c === 'string')
|
|
703
|
+
return c;
|
|
704
|
+
if (typeof c === 'object' && 'name' in c)
|
|
705
|
+
return c.name;
|
|
706
|
+
return String(c);
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Maps categories and series data into a flat array of objects suitable for Pie/Ring/Funnel charts.
|
|
711
|
+
*/
|
|
712
|
+
function mapToChartItems(categories, seriesNode) {
|
|
713
|
+
if (!categories || !seriesNode || !seriesNode.data)
|
|
714
|
+
return [];
|
|
715
|
+
return categories.map((catNode, catIndex) => ({
|
|
716
|
+
name: catNode.name,
|
|
717
|
+
value: getCellValue(seriesNode.data[catIndex]),
|
|
718
|
+
originalMeassureKey: seriesNode.originalKey || getCategoryKey(categories, catIndex)
|
|
719
|
+
}));
|
|
720
|
+
}
|
|
585
721
|
/**
|
|
586
722
|
* Formatter generator for 'item' trigger strategy in tooltips.
|
|
587
723
|
*/
|
|
588
|
-
function getItemTooltipFormatter(data, formatCellValue) {
|
|
724
|
+
function getItemTooltipFormatter(data, formatCellValue, opts) {
|
|
589
725
|
const totalSeries = data.series.length;
|
|
590
726
|
return (params) => {
|
|
727
|
+
const showSerieName = opts?.showSerieName ?? true;
|
|
591
728
|
const seriesObj = data.series[params.seriesIndex];
|
|
592
|
-
const key = params.data?.originalMeassureKey || seriesObj?.originalKey || (data.
|
|
729
|
+
const key = params.data?.originalMeassureKey || seriesObj?.originalKey || getCategoryKey(data.categories, params.dataIndex);
|
|
593
730
|
const valFormatted = formatCellValue(params.value, key);
|
|
731
|
+
const serieName = showSerieName ? `${params.marker} ${params.seriesName}<br/ >` : '';
|
|
732
|
+
//TODO: Unificar salida del tooltip
|
|
594
733
|
if (params.percent !== undefined) {
|
|
595
|
-
const seriesHeader = totalSeries > 1 ?
|
|
596
|
-
return
|
|
734
|
+
const seriesHeader = totalSeries > 1 ? serieName : '';
|
|
735
|
+
return `<div style="text-align: center;"><b>${params.name}</b><br/>${seriesHeader} <b>${valFormatted}</b> (${params.percent}%)</div>`;
|
|
597
736
|
}
|
|
598
|
-
return `<div style="text-align: center;"><b>${params.name}</b><br/>${
|
|
737
|
+
return `<div style="text-align: center;"><b>${params.name}</b><br/>${serieName}<b>${valFormatted}</b></div>`;
|
|
599
738
|
};
|
|
600
739
|
}
|
|
601
740
|
/**
|
|
602
741
|
* Formatter generator for 'axis' trigger strategy in tooltips.
|
|
603
742
|
*/
|
|
604
|
-
function getAxisTooltipFormatter(data, formatCellValue) {
|
|
743
|
+
function getAxisTooltipFormatter(data, formatCellValue, opts) {
|
|
605
744
|
return (params) => {
|
|
606
745
|
if (!params)
|
|
607
746
|
return '';
|
|
@@ -614,7 +753,7 @@ function getAxisTooltipFormatter(data, formatCellValue) {
|
|
|
614
753
|
const seriesObj = data.series[item.seriesIndex];
|
|
615
754
|
if (!seriesObj)
|
|
616
755
|
continue;
|
|
617
|
-
const key = seriesObj.originalKey || (data.
|
|
756
|
+
const key = seriesObj.originalKey || getCategoryKey(data.categories, item.dataIndex);
|
|
618
757
|
const valFormatted = formatCellValue(item.value, key);
|
|
619
758
|
html += `${item.marker} ${item.seriesName}: <b>${valFormatted}</b><br/>`;
|
|
620
759
|
}
|
|
@@ -624,10 +763,10 @@ function getAxisTooltipFormatter(data, formatCellValue) {
|
|
|
624
763
|
/**
|
|
625
764
|
* Unified tooltip formatter generator that selects the appropriate strategy based on the trigger.
|
|
626
765
|
*/
|
|
627
|
-
function getTooltipFormatter(trigger, data, formatCellValue) {
|
|
766
|
+
function getTooltipFormatter(trigger, data, formatCellValue, opts) {
|
|
628
767
|
return trigger === 'axis'
|
|
629
|
-
? getAxisTooltipFormatter(data, formatCellValue)
|
|
630
|
-
: getItemTooltipFormatter(data, formatCellValue);
|
|
768
|
+
? getAxisTooltipFormatter(data, formatCellValue, opts)
|
|
769
|
+
: getItemTooltipFormatter(data, formatCellValue, opts);
|
|
631
770
|
}
|
|
632
771
|
function getCommons(opts) {
|
|
633
772
|
const palette = opts?.palette ?? getDefaultPalette();
|
|
@@ -648,6 +787,83 @@ function getCommons(opts) {
|
|
|
648
787
|
common.color = (palette && palette.length > 0) ? palette : getDefaultPalette();
|
|
649
788
|
return common;
|
|
650
789
|
}
|
|
790
|
+
/**
|
|
791
|
+
* Maps hierarchical category nodes and an array of series into a nested structure
|
|
792
|
+
* suitable for Sunburst/Treemap charts.
|
|
793
|
+
* The categories form the levels closest to the center, and the series form the leaf level.
|
|
794
|
+
*/
|
|
795
|
+
function mapHierarchicalData(categories, series) {
|
|
796
|
+
if (!categories) {
|
|
797
|
+
return [];
|
|
798
|
+
}
|
|
799
|
+
let leafIndex = 0;
|
|
800
|
+
function mapSeriesTree(seriesNodes, index) {
|
|
801
|
+
if (!seriesNodes) {
|
|
802
|
+
return [];
|
|
803
|
+
}
|
|
804
|
+
return seriesNodes.map(s => {
|
|
805
|
+
const node = {
|
|
806
|
+
name: s.name,
|
|
807
|
+
};
|
|
808
|
+
if (s.children && s.children.length > 0) {
|
|
809
|
+
node.children = mapSeriesTree(s.children, index);
|
|
810
|
+
}
|
|
811
|
+
else {
|
|
812
|
+
// Leaf series node: extract value from s.data[index]
|
|
813
|
+
const dataVal = s.data?.[index];
|
|
814
|
+
if (dataVal !== undefined && dataVal !== null) {
|
|
815
|
+
const value = typeof dataVal === 'object' && 'value' in dataVal ? dataVal.value : dataVal;
|
|
816
|
+
node.value = getCellValue(value);
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
node.value = 0;
|
|
820
|
+
}
|
|
821
|
+
node.originalMeassureKey = s.originalKey;
|
|
822
|
+
}
|
|
823
|
+
return node;
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
function traverse(nodes) {
|
|
827
|
+
return nodes.map(cat => {
|
|
828
|
+
const node = {
|
|
829
|
+
name: cat.name,
|
|
830
|
+
};
|
|
831
|
+
if (cat.children && cat.children.length > 0) {
|
|
832
|
+
node.children = traverse(cat.children);
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
// Leaf category node: append the series tree as children
|
|
836
|
+
if (series && series.length > 0) {
|
|
837
|
+
node.children = mapSeriesTree(series, leafIndex);
|
|
838
|
+
}
|
|
839
|
+
else {
|
|
840
|
+
node.value = 0;
|
|
841
|
+
}
|
|
842
|
+
leafIndex++;
|
|
843
|
+
}
|
|
844
|
+
return node;
|
|
845
|
+
});
|
|
846
|
+
}
|
|
847
|
+
return traverse(categories);
|
|
848
|
+
}
|
|
849
|
+
/**
|
|
850
|
+
* Calculates the maximum depth of a tree structure.
|
|
851
|
+
*/
|
|
852
|
+
function getTreeDepth(nodes) {
|
|
853
|
+
if (!nodes || nodes.length === 0) {
|
|
854
|
+
return 0;
|
|
855
|
+
}
|
|
856
|
+
let maxChildDepth = 0;
|
|
857
|
+
for (const node of nodes) {
|
|
858
|
+
if (node.children && node.children.length > 0) {
|
|
859
|
+
const d = getTreeDepth(node.children);
|
|
860
|
+
if (d > maxChildDepth) {
|
|
861
|
+
maxChildDepth = d;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
return 1 + maxChildDepth;
|
|
866
|
+
}
|
|
651
867
|
|
|
652
868
|
/**
|
|
653
869
|
* RingBuilder
|
|
@@ -675,9 +891,10 @@ class RingBuilder {
|
|
|
675
891
|
merge(this.result, common);
|
|
676
892
|
}
|
|
677
893
|
addSeries(data, overrides) {
|
|
678
|
-
|
|
894
|
+
const flatData = flattenEChartData(data);
|
|
895
|
+
if (!flatData || !flatData.series.length)
|
|
679
896
|
return;
|
|
680
|
-
const totalRings =
|
|
897
|
+
const totalRings = flatData.series.length; // Cada serie es un anillo
|
|
681
898
|
// Configuración dinámica de radios y márgenes
|
|
682
899
|
const margin = totalRings > 1 ? Math.max(0.5, 2.5 - (totalRings * 0.1)) : 0;
|
|
683
900
|
const minInnerRadius = totalRings === 1 ? 45 : (totalRings > 5 ? Math.max(15, 40 - (totalRings * 1.2)) : 40);
|
|
@@ -686,14 +903,10 @@ class RingBuilder {
|
|
|
686
903
|
const thickness = availableSpan / totalRings;
|
|
687
904
|
const borderRadius = totalRings === 1 ? 10 : Math.max(2, Math.min(10, thickness * 0.8));
|
|
688
905
|
const borderWidth = totalRings === 1 ? 2 : Math.max(0.5, Math.min(2, thickness * 0.15));
|
|
689
|
-
const series =
|
|
906
|
+
const series = flatData.series.map((s, ringIndex) => {
|
|
690
907
|
const inner = minInnerRadius + (ringIndex * (thickness + margin));
|
|
691
908
|
const outer = inner + thickness;
|
|
692
|
-
const pieData =
|
|
693
|
-
name: catName,
|
|
694
|
-
value: s.data[catIndex],
|
|
695
|
-
originalMeassureKey: s.originalKey || (data.categoryKeys ? data.categoryKeys[catIndex] : '')
|
|
696
|
-
}));
|
|
909
|
+
const pieData = mapToChartItems(flatData.categories, s);
|
|
697
910
|
const dynamicRingSeriesOptions = {
|
|
698
911
|
name: s.name,
|
|
699
912
|
radius: [`${inner}%`, `${outer}%`],
|
|
@@ -747,8 +960,9 @@ class RingBuilder {
|
|
|
747
960
|
}];
|
|
748
961
|
}
|
|
749
962
|
addTooltip(data, overrides) {
|
|
963
|
+
const flatData = flattenEChartData(data);
|
|
750
964
|
merge(overrides, {
|
|
751
|
-
formatter: getTooltipFormatter(overrides.trigger,
|
|
965
|
+
formatter: getTooltipFormatter(overrides.trigger, flatData, this.formatCellValue.bind(this)),
|
|
752
966
|
});
|
|
753
967
|
const tooltip = getTooltipOptions(overrides);
|
|
754
968
|
this.result.tooltip = tooltip;
|
|
@@ -927,6 +1141,21 @@ class VSECDirector {
|
|
|
927
1141
|
this.builder.addTooltip(data, overrides.tooltip);
|
|
928
1142
|
this.builder.addLegend();
|
|
929
1143
|
}
|
|
1144
|
+
makeSunburst(data, overrides, opts = {}) {
|
|
1145
|
+
const { valueFormatter = undefined, palette = undefined, colorResolver = undefined, } = opts;
|
|
1146
|
+
this.builder.reset();
|
|
1147
|
+
// El orden importa, primero callbacks y despues componentes.
|
|
1148
|
+
this.builder.setValueFormatter(valueFormatter);
|
|
1149
|
+
this.builder.setPalette(palette);
|
|
1150
|
+
this.builder.setColorResolver(colorResolver);
|
|
1151
|
+
const product = this.builder.baseProduct;
|
|
1152
|
+
const seriesOverrides = merge$1({}, product.baseOptions.series, overrides[product.chartKey].series);
|
|
1153
|
+
// chart components
|
|
1154
|
+
this.builder.addCommons();
|
|
1155
|
+
this.builder.addSeries(data, seriesOverrides);
|
|
1156
|
+
this.builder.addTooltip(data, overrides.tooltip);
|
|
1157
|
+
// this.builder.addLegend();
|
|
1158
|
+
}
|
|
930
1159
|
}
|
|
931
1160
|
|
|
932
1161
|
/**
|
|
@@ -977,7 +1206,12 @@ class EchartsRingComponent extends BaseEchartsComponent {
|
|
|
977
1206
|
constructor() {
|
|
978
1207
|
super();
|
|
979
1208
|
}
|
|
980
|
-
make(
|
|
1209
|
+
make() {
|
|
1210
|
+
const makeOpts = {
|
|
1211
|
+
valueFormatter: this.valueFormatter,
|
|
1212
|
+
palette: this.palette,
|
|
1213
|
+
colorResolver: this.colorResolver,
|
|
1214
|
+
};
|
|
981
1215
|
this.director.makeRing(this.data, this.optionsOverrides, makeOpts);
|
|
982
1216
|
}
|
|
983
1217
|
onInputChanges(changes) {
|
|
@@ -1047,22 +1281,6 @@ class EchartsRingComponent extends BaseEchartsComponent {
|
|
|
1047
1281
|
}
|
|
1048
1282
|
});
|
|
1049
1283
|
}
|
|
1050
|
-
updateChartOptions() {
|
|
1051
|
-
if (!this.chartInstance)
|
|
1052
|
-
return;
|
|
1053
|
-
if (!this.data)
|
|
1054
|
-
return;
|
|
1055
|
-
// 1. Configuramos el builder (Formateadores, Colores, etc se manejan en la base)
|
|
1056
|
-
const makeOpts = {
|
|
1057
|
-
valueFormatter: this.valueFormatter,
|
|
1058
|
-
palette: this.palette,
|
|
1059
|
-
colorResolver: this.colorResolver,
|
|
1060
|
-
};
|
|
1061
|
-
this.make(makeOpts);
|
|
1062
|
-
// 2. Obtenemos las bases del chart usando el builder
|
|
1063
|
-
const options = this.builder.getResult();
|
|
1064
|
-
this.triggerUpdate(options);
|
|
1065
|
-
}
|
|
1066
1284
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EchartsRingComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1067
1285
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: EchartsRingComponent, isStandalone: true, selector: "vs-echarts-ring", providers: [provideVSEcharts()], usesInheritance: true, ngImport: i0, template: "<div class=\"echarts-container\" \n echarts \n [options]=\"{}\"\n [initOpts]=\"initOptions\"\n [autoResize]=\"true\" \n (chartInit)=\"onChartInit($event)\" \n (chartClick)=\"onChartClick($event)\" \n (chartMouseOver)=\"onChartMouseOver($event)\" \n (chartMouseOut)=\"onChartMouseOut($event)\" \n (chartSelectChanged)=\"onChartSelectChanged($event, { fixPieDataIndexInside: true })\"\n></div>\n ", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: NgxEchartsDirective, selector: "echarts, [echarts]", inputs: ["options", "theme", "initOpts", "merge", "autoResize", "loading", "loadingType", "loadingOpts"], outputs: ["chartInit", "optionsError", "chartClick", "chartDblClick", "chartMouseDown", "chartMouseMove", "chartMouseUp", "chartMouseOver", "chartMouseOut", "chartGlobalOut", "chartContextMenu", "chartHighlight", "chartDownplay", "chartSelectChanged", "chartLegendSelectChanged", "chartLegendSelected", "chartLegendUnselected", "chartLegendLegendSelectAll", "chartLegendLegendInverseSelect", "chartLegendScroll", "chartDataZoom", "chartDataRangeSelected", "chartGraphRoam", "chartGeoRoam", "chartTreeRoam", "chartTimelineChanged", "chartTimelinePlayChanged", "chartRestore", "chartDataViewChanged", "chartMagicTypeChanged", "chartGeoSelectChanged", "chartGeoSelected", "chartGeoUnselected", "chartAxisAreaSelected", "chartBrush", "chartBrushEnd", "chartBrushSelected", "chartGlobalCursorTaken", "chartRendered", "chartFinished"], exportAs: ["echarts"] }] });
|
|
1068
1286
|
}
|
|
@@ -1100,17 +1318,14 @@ class PieBuilder {
|
|
|
1100
1318
|
merge(this.result, common);
|
|
1101
1319
|
}
|
|
1102
1320
|
addSeries(data, overrides) {
|
|
1103
|
-
|
|
1321
|
+
const flatData = flattenEChartData(data);
|
|
1322
|
+
if (!flatData || !flatData.series.length)
|
|
1104
1323
|
return;
|
|
1105
|
-
const totalSeries =
|
|
1324
|
+
const totalSeries = flatData.series.length;
|
|
1106
1325
|
let series = [];
|
|
1107
1326
|
if (totalSeries === 1) {
|
|
1108
|
-
const s =
|
|
1109
|
-
const pieData =
|
|
1110
|
-
name: catName,
|
|
1111
|
-
value: s.data[catIndex],
|
|
1112
|
-
originalMeassureKey: s.originalKey || (data.categoryKeys ? data.categoryKeys[catIndex] : '')
|
|
1113
|
-
}));
|
|
1327
|
+
const s = flatData.series[0];
|
|
1328
|
+
const pieData = mapToChartItems(flatData.categories, s);
|
|
1114
1329
|
const dynamicPieSeriesOptions = {
|
|
1115
1330
|
name: s.name,
|
|
1116
1331
|
type: 'pie',
|
|
@@ -1139,12 +1354,8 @@ class PieBuilder {
|
|
|
1139
1354
|
const numRings = totalSeries - 1;
|
|
1140
1355
|
const availableSpan = maxOuterRadius - (centerPieRadius + margin) - (margin * (numRings - 1));
|
|
1141
1356
|
const thickness = availableSpan / numRings;
|
|
1142
|
-
series =
|
|
1143
|
-
const pieData =
|
|
1144
|
-
name: catName,
|
|
1145
|
-
value: s.data[catIndex],
|
|
1146
|
-
originalMeassureKey: s.originalKey || (data.categoryKeys ? data.categoryKeys[catIndex] : '')
|
|
1147
|
-
}));
|
|
1357
|
+
series = flatData.series.map((s, idx) => {
|
|
1358
|
+
const pieData = mapToChartItems(flatData.categories, s);
|
|
1148
1359
|
let radius;
|
|
1149
1360
|
let labelPosition;
|
|
1150
1361
|
let labelLineShow;
|
|
@@ -1189,8 +1400,9 @@ class PieBuilder {
|
|
|
1189
1400
|
this.result.series = series;
|
|
1190
1401
|
}
|
|
1191
1402
|
addTooltip(data, overrides) {
|
|
1403
|
+
const flatData = flattenEChartData(data);
|
|
1192
1404
|
merge(overrides, {
|
|
1193
|
-
formatter: getTooltipFormatter(overrides.trigger,
|
|
1405
|
+
formatter: getTooltipFormatter(overrides.trigger, flatData, this.formatCellValue.bind(this)),
|
|
1194
1406
|
});
|
|
1195
1407
|
const tooltip = getTooltipOptions(overrides);
|
|
1196
1408
|
this.result.tooltip = tooltip;
|
|
@@ -1270,24 +1482,13 @@ class EchartsPieComponent extends BaseEchartsComponent {
|
|
|
1270
1482
|
constructor() {
|
|
1271
1483
|
super();
|
|
1272
1484
|
}
|
|
1273
|
-
make(
|
|
1274
|
-
this.director.makePie(this.data, this.optionsOverrides, makeOpts);
|
|
1275
|
-
}
|
|
1276
|
-
updateChartOptions() {
|
|
1277
|
-
if (!this.chartInstance)
|
|
1278
|
-
return;
|
|
1279
|
-
if (!this.data)
|
|
1280
|
-
return;
|
|
1281
|
-
// 1. Configuramos el builder
|
|
1485
|
+
make() {
|
|
1282
1486
|
const makeOpts = {
|
|
1283
1487
|
valueFormatter: this.valueFormatter,
|
|
1284
1488
|
palette: this.palette,
|
|
1285
1489
|
colorResolver: this.colorResolver,
|
|
1286
1490
|
};
|
|
1287
|
-
this.
|
|
1288
|
-
// 2. Obtenemos las bases del chart usando el builder
|
|
1289
|
-
const options = this.builder.getResult();
|
|
1290
|
-
this.triggerUpdate(options);
|
|
1491
|
+
this.director.makePie(this.data, this.optionsOverrides, makeOpts);
|
|
1291
1492
|
}
|
|
1292
1493
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EchartsPieComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1293
1494
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: EchartsPieComponent, isStandalone: true, selector: "vs-echarts-pie", providers: [provideVSEcharts()], usesInheritance: true, ngImport: i0, template: "<div\n class=\"echarts-container\"\n echarts\n [options]=\"{}\"\n [initOpts]=\"initOptions\"\n [autoResize]=\"true\"\n (chartInit)=\"onChartInit($event)\"\n (chartClick)=\"onChartClick($event)\"\n (chartSelectChanged)=\"onChartSelectChanged($event, { fixPieDataIndexInside: true })\"\n></div>\n", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: NgxEchartsDirective, selector: "echarts, [echarts]", inputs: ["options", "theme", "initOpts", "merge", "autoResize", "loading", "loadingType", "loadingOpts"], outputs: ["chartInit", "optionsError", "chartClick", "chartDblClick", "chartMouseDown", "chartMouseMove", "chartMouseUp", "chartMouseOver", "chartMouseOut", "chartGlobalOut", "chartContextMenu", "chartHighlight", "chartDownplay", "chartSelectChanged", "chartLegendSelectChanged", "chartLegendSelected", "chartLegendUnselected", "chartLegendLegendSelectAll", "chartLegendLegendInverseSelect", "chartLegendScroll", "chartDataZoom", "chartDataRangeSelected", "chartGraphRoam", "chartGeoRoam", "chartTreeRoam", "chartTimelineChanged", "chartTimelinePlayChanged", "chartRestore", "chartDataViewChanged", "chartMagicTypeChanged", "chartGeoSelectChanged", "chartGeoSelected", "chartGeoUnselected", "chartAxisAreaSelected", "chartBrush", "chartBrushEnd", "chartBrushSelected", "chartGlobalCursorTaken", "chartRendered", "chartFinished"], exportAs: ["echarts"] }] });
|
|
@@ -1325,14 +1526,11 @@ class FunnelBuilder {
|
|
|
1325
1526
|
merge(this.result, common);
|
|
1326
1527
|
}
|
|
1327
1528
|
addSeries(data, overrides) {
|
|
1328
|
-
|
|
1529
|
+
const flatData = flattenEChartData(data);
|
|
1530
|
+
if (!flatData || !flatData.series.length)
|
|
1329
1531
|
return;
|
|
1330
|
-
const series =
|
|
1331
|
-
const funnelData =
|
|
1332
|
-
name: catName,
|
|
1333
|
-
value: s.data[catIndex],
|
|
1334
|
-
originalMeassureKey: s.originalKey || (data.categoryKeys ? data.categoryKeys[catIndex] : '')
|
|
1335
|
-
}));
|
|
1532
|
+
const series = flatData.series.map((s, seriesIndex) => {
|
|
1533
|
+
const funnelData = mapToChartItems(flatData.categories, s);
|
|
1336
1534
|
let left = '10%';
|
|
1337
1535
|
let width = '80%';
|
|
1338
1536
|
const seriesValues = s.data.filter(val => typeof val === 'number');
|
|
@@ -1358,8 +1556,9 @@ class FunnelBuilder {
|
|
|
1358
1556
|
this.result.series = series.shift();
|
|
1359
1557
|
}
|
|
1360
1558
|
addTooltip(data, overrides) {
|
|
1559
|
+
const flatData = flattenEChartData(data);
|
|
1361
1560
|
merge(overrides, {
|
|
1362
|
-
formatter: getTooltipFormatter(overrides.trigger,
|
|
1561
|
+
formatter: getTooltipFormatter(overrides.trigger, flatData, this.formatCellValue.bind(this)),
|
|
1363
1562
|
});
|
|
1364
1563
|
const tooltip = getTooltipOptions(overrides);
|
|
1365
1564
|
this.result.tooltip = tooltip;
|
|
@@ -1452,22 +1651,13 @@ class EchartsFunnelComponent extends BaseEchartsComponent {
|
|
|
1452
1651
|
constructor() {
|
|
1453
1652
|
super();
|
|
1454
1653
|
}
|
|
1455
|
-
make(
|
|
1456
|
-
this.director.makeFunnel(this.data, this.optionsOverrides, makeOpts);
|
|
1457
|
-
}
|
|
1458
|
-
updateChartOptions() {
|
|
1459
|
-
if (!this.chartInstance)
|
|
1460
|
-
return;
|
|
1461
|
-
if (!this.data)
|
|
1462
|
-
return;
|
|
1654
|
+
make() {
|
|
1463
1655
|
const makeOpts = {
|
|
1464
1656
|
valueFormatter: this.valueFormatter,
|
|
1465
1657
|
palette: this.palette,
|
|
1466
1658
|
colorResolver: this.colorResolver,
|
|
1467
1659
|
};
|
|
1468
|
-
this.
|
|
1469
|
-
const options = this.builder.getResult();
|
|
1470
|
-
this.triggerUpdate(options);
|
|
1660
|
+
this.director.makeFunnel(this.data, this.optionsOverrides, makeOpts);
|
|
1471
1661
|
}
|
|
1472
1662
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EchartsFunnelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1473
1663
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: EchartsFunnelComponent, isStandalone: true, selector: "vs-echarts-funnel", providers: [provideVSEcharts()], usesInheritance: true, ngImport: i0, template: "<div class=\"echarts-container\" echarts \n [options]=\"{}\"\n [initOpts]=\"initOptions\" \n [autoResize]=\"true\" \n (chartInit)=\"onChartInit($event)\" \n (chartClick)=\"onChartClick($event)\" \n (chartSelectChanged)=\"onChartSelectChanged($event, { fixPieDataIndexInside: true })\"\n></div>\n", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: NgxEchartsDirective, selector: "echarts, [echarts]", inputs: ["options", "theme", "initOpts", "merge", "autoResize", "loading", "loadingType", "loadingOpts"], outputs: ["chartInit", "optionsError", "chartClick", "chartDblClick", "chartMouseDown", "chartMouseMove", "chartMouseUp", "chartMouseOver", "chartMouseOut", "chartGlobalOut", "chartContextMenu", "chartHighlight", "chartDownplay", "chartSelectChanged", "chartLegendSelectChanged", "chartLegendSelected", "chartLegendUnselected", "chartLegendLegendSelectAll", "chartLegendLegendInverseSelect", "chartLegendScroll", "chartDataZoom", "chartDataRangeSelected", "chartGraphRoam", "chartGeoRoam", "chartTreeRoam", "chartTimelineChanged", "chartTimelinePlayChanged", "chartRestore", "chartDataViewChanged", "chartMagicTypeChanged", "chartGeoSelectChanged", "chartGeoSelected", "chartGeoUnselected", "chartAxisAreaSelected", "chartBrush", "chartBrushEnd", "chartBrushSelected", "chartGlobalCursorTaken", "chartRendered", "chartFinished"], exportAs: ["echarts"] }] });
|
|
@@ -1513,15 +1703,16 @@ class EChartBuilder {
|
|
|
1513
1703
|
* @returns
|
|
1514
1704
|
*/
|
|
1515
1705
|
addSeries(data, overrides) {
|
|
1516
|
-
|
|
1706
|
+
const flatData = flattenEChartData(data);
|
|
1707
|
+
if (!flatData || !flatData.series.length)
|
|
1517
1708
|
return;
|
|
1518
|
-
const series =
|
|
1709
|
+
const series = flatData.series.map((s) => {
|
|
1519
1710
|
const dynamicOverrides = {
|
|
1520
1711
|
name: s.name,
|
|
1521
1712
|
data: s.data,
|
|
1522
1713
|
label: {
|
|
1523
1714
|
formatter: (params) => {
|
|
1524
|
-
const key = s.originalKey || (
|
|
1715
|
+
const key = s.originalKey || getCategoryKey(flatData.categories, params.dataIndex);
|
|
1525
1716
|
return this.formatCellValue(params.value, key);
|
|
1526
1717
|
}
|
|
1527
1718
|
}
|
|
@@ -1542,8 +1733,9 @@ class EChartBuilder {
|
|
|
1542
1733
|
*/
|
|
1543
1734
|
addTooltip(data, overrides) {
|
|
1544
1735
|
// inyecto formateador a overrides de tooltip
|
|
1736
|
+
const flatData = flattenEChartData(data);
|
|
1545
1737
|
merge$1(overrides, {
|
|
1546
|
-
formatter: getTooltipFormatter(overrides.trigger,
|
|
1738
|
+
formatter: getTooltipFormatter(overrides.trigger, flatData, this.formatCellValue.bind(this)),
|
|
1547
1739
|
});
|
|
1548
1740
|
const tooltip = getTooltipOptions(overrides);
|
|
1549
1741
|
this.result.tooltip = tooltip;
|
|
@@ -1660,9 +1852,10 @@ class EChartBuilder {
|
|
|
1660
1852
|
}
|
|
1661
1853
|
// Utils
|
|
1662
1854
|
getCategoryAxisOptions(data, overrides) {
|
|
1855
|
+
const flatCategories = flattenCategoriesToFirstLevel(data.categories);
|
|
1663
1856
|
const categoryAxisOptionsOverrides = {
|
|
1664
1857
|
...overrides.categoryAxis[0],
|
|
1665
|
-
data:
|
|
1858
|
+
data: resolveCategoryNames(flatCategories),
|
|
1666
1859
|
};
|
|
1667
1860
|
const categoryAxisOptions = getCategoryAxisOptions(categoryAxisOptionsOverrides);
|
|
1668
1861
|
return categoryAxisOptions;
|
|
@@ -1720,23 +1913,13 @@ class EchartsBarComponent extends BaseEchartsComponent {
|
|
|
1720
1913
|
constructor() {
|
|
1721
1914
|
super();
|
|
1722
1915
|
}
|
|
1723
|
-
|
|
1724
|
-
make(makeOpts) {
|
|
1725
|
-
this.director.makeBar(this.data, this.optionsOverrides, makeOpts);
|
|
1726
|
-
}
|
|
1727
|
-
updateChartOptions() {
|
|
1728
|
-
if (!this.chartInstance)
|
|
1729
|
-
return;
|
|
1730
|
-
if (!this.data)
|
|
1731
|
-
return;
|
|
1916
|
+
make() {
|
|
1732
1917
|
const makeBarOpts = {
|
|
1733
1918
|
valueFormatter: this.valueFormatter,
|
|
1734
1919
|
palette: this.palette,
|
|
1735
1920
|
colorResolver: this.colorResolver,
|
|
1736
1921
|
};
|
|
1737
|
-
this.
|
|
1738
|
-
const baseOptions = this.builder.getResult();
|
|
1739
|
-
this.triggerUpdate(baseOptions);
|
|
1922
|
+
this.director.makeBar(this.data, this.optionsOverrides, makeBarOpts);
|
|
1740
1923
|
}
|
|
1741
1924
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EchartsBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1742
1925
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: EchartsBarComponent, isStandalone: true, selector: "vs-echarts-bar", providers: [provideVSEcharts()], usesInheritance: true, ngImport: i0, template: "<div class=\"echarts-container\" echarts \n [options]=\"{}\"\n [initOpts]=\"initOptions\" \n [autoResize]=\"true\" \n (chartInit)=\"onChartInit($event)\" \n (chartClick)=\"onChartClick($event)\" \n (chartSelectChanged)=\"onChartSelectChanged($event)\"\n></div>\n", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: NgxEchartsDirective, selector: "echarts, [echarts]", inputs: ["options", "theme", "initOpts", "merge", "autoResize", "loading", "loadingType", "loadingOpts"], outputs: ["chartInit", "optionsError", "chartClick", "chartDblClick", "chartMouseDown", "chartMouseMove", "chartMouseUp", "chartMouseOver", "chartMouseOut", "chartGlobalOut", "chartContextMenu", "chartHighlight", "chartDownplay", "chartSelectChanged", "chartLegendSelectChanged", "chartLegendSelected", "chartLegendUnselected", "chartLegendLegendSelectAll", "chartLegendLegendInverseSelect", "chartLegendScroll", "chartDataZoom", "chartDataRangeSelected", "chartGraphRoam", "chartGeoRoam", "chartTreeRoam", "chartTimelineChanged", "chartTimelinePlayChanged", "chartRestore", "chartDataViewChanged", "chartMagicTypeChanged", "chartGeoSelectChanged", "chartGeoSelected", "chartGeoUnselected", "chartAxisAreaSelected", "chartBrush", "chartBrushEnd", "chartBrushSelected", "chartGlobalCursorTaken", "chartRendered", "chartFinished"], exportAs: ["echarts"] }] });
|
|
@@ -1764,10 +1947,15 @@ class EChartsHBarComponent extends EchartsBarComponent {
|
|
|
1764
1947
|
};
|
|
1765
1948
|
builder = new EChartBuilder(this.variantBaseProduct);
|
|
1766
1949
|
director = new VSECDirector(this.builder);
|
|
1767
|
-
make(
|
|
1768
|
-
makeOpts
|
|
1769
|
-
|
|
1770
|
-
|
|
1950
|
+
make() {
|
|
1951
|
+
const makeOpts = {
|
|
1952
|
+
valueFormatter: this.valueFormatter,
|
|
1953
|
+
palette: this.palette,
|
|
1954
|
+
colorResolver: this.colorResolver,
|
|
1955
|
+
axisTypes: {
|
|
1956
|
+
x: 'value',
|
|
1957
|
+
y: 'category',
|
|
1958
|
+
},
|
|
1771
1959
|
};
|
|
1772
1960
|
this.director.makeBar(this.data, this.optionsOverrides, makeOpts);
|
|
1773
1961
|
}
|
|
@@ -1831,10 +2019,15 @@ class EChartsHBarStackedComponent extends EchartsBarComponent {
|
|
|
1831
2019
|
};
|
|
1832
2020
|
builder = new EChartBuilder(this.variantBaseProduct);
|
|
1833
2021
|
director = new VSECDirector(this.builder);
|
|
1834
|
-
make(
|
|
1835
|
-
makeOpts
|
|
1836
|
-
|
|
1837
|
-
|
|
2022
|
+
make() {
|
|
2023
|
+
const makeOpts = {
|
|
2024
|
+
valueFormatter: this.valueFormatter,
|
|
2025
|
+
palette: this.palette,
|
|
2026
|
+
colorResolver: this.colorResolver,
|
|
2027
|
+
axisTypes: {
|
|
2028
|
+
x: 'value',
|
|
2029
|
+
y: 'category',
|
|
2030
|
+
},
|
|
1838
2031
|
};
|
|
1839
2032
|
this.director.makeBar(this.data, this.optionsOverrides, makeOpts);
|
|
1840
2033
|
}
|
|
@@ -1869,7 +2062,12 @@ class EChartsBarStackedRadialComponent extends EchartsBarComponent {
|
|
|
1869
2062
|
};
|
|
1870
2063
|
builder = new EChartBuilder(this.variantBaseProduct);
|
|
1871
2064
|
director = new VSECDirector(this.builder);
|
|
1872
|
-
make(
|
|
2065
|
+
make() {
|
|
2066
|
+
const makeOpts = {
|
|
2067
|
+
valueFormatter: this.valueFormatter,
|
|
2068
|
+
palette: this.palette,
|
|
2069
|
+
colorResolver: this.colorResolver,
|
|
2070
|
+
};
|
|
1873
2071
|
this.director.makeBarRadial(this.data, this.optionsOverrides, makeOpts);
|
|
1874
2072
|
}
|
|
1875
2073
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EChartsBarStackedRadialComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
@@ -1933,22 +2131,13 @@ class EchartsLineComponent extends BaseEchartsComponent {
|
|
|
1933
2131
|
constructor() {
|
|
1934
2132
|
super();
|
|
1935
2133
|
}
|
|
1936
|
-
make(
|
|
1937
|
-
|
|
1938
|
-
}
|
|
1939
|
-
updateChartOptions() {
|
|
1940
|
-
if (!this.chartInstance)
|
|
1941
|
-
return;
|
|
1942
|
-
if (!this.data)
|
|
1943
|
-
return;
|
|
1944
|
-
const makeBarOpts = {
|
|
2134
|
+
make() {
|
|
2135
|
+
const makeOpts = {
|
|
1945
2136
|
valueFormatter: this.valueFormatter,
|
|
1946
2137
|
palette: this.palette,
|
|
1947
2138
|
colorResolver: this.colorResolver,
|
|
1948
2139
|
};
|
|
1949
|
-
this.
|
|
1950
|
-
const baseOptions = this.builder.getResult();
|
|
1951
|
-
this.triggerUpdate(baseOptions);
|
|
2140
|
+
this.director.makeLine(this.data, this.optionsOverrides, makeOpts);
|
|
1952
2141
|
}
|
|
1953
2142
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EchartsLineComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1954
2143
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: EchartsLineComponent, isStandalone: true, selector: "vs-echarts-line", providers: [
|
|
@@ -2059,22 +2248,13 @@ class EchartsScatterComponent extends BaseEchartsComponent {
|
|
|
2059
2248
|
constructor() {
|
|
2060
2249
|
super();
|
|
2061
2250
|
}
|
|
2062
|
-
make(
|
|
2063
|
-
|
|
2064
|
-
}
|
|
2065
|
-
updateChartOptions() {
|
|
2066
|
-
if (!this.chartInstance)
|
|
2067
|
-
return;
|
|
2068
|
-
if (!this.data)
|
|
2069
|
-
return;
|
|
2070
|
-
const makeScatterOpts = {
|
|
2251
|
+
make() {
|
|
2252
|
+
const makeOpts = {
|
|
2071
2253
|
valueFormatter: this.valueFormatter,
|
|
2072
2254
|
palette: this.palette,
|
|
2073
2255
|
colorResolver: this.colorResolver,
|
|
2074
2256
|
};
|
|
2075
|
-
this.
|
|
2076
|
-
const baseOptions = this.builder.getResult();
|
|
2077
|
-
this.triggerUpdate(baseOptions);
|
|
2257
|
+
this.director.makeScatter(this.data, this.optionsOverrides, makeOpts);
|
|
2078
2258
|
}
|
|
2079
2259
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EchartsScatterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2080
2260
|
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: EchartsScatterComponent, isStandalone: true, selector: "vs-echarts-scatter", providers: [provideVSEcharts()], usesInheritance: true, ngImport: i0, template: "<div class=\"echarts-container\" echarts \n [options]=\"{}\"\n [initOpts]=\"initOptions\" \n [autoResize]=\"true\" \n (chartInit)=\"onChartInit($event)\" \n (chartClick)=\"onChartClick($event)\" \n (chartSelectChanged)=\"onChartSelectChanged($event)\"\n></div>\n", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: NgxEchartsDirective, selector: "echarts, [echarts]", inputs: ["options", "theme", "initOpts", "merge", "autoResize", "loading", "loadingType", "loadingOpts"], outputs: ["chartInit", "optionsError", "chartClick", "chartDblClick", "chartMouseDown", "chartMouseMove", "chartMouseUp", "chartMouseOver", "chartMouseOut", "chartGlobalOut", "chartContextMenu", "chartHighlight", "chartDownplay", "chartSelectChanged", "chartLegendSelectChanged", "chartLegendSelected", "chartLegendUnselected", "chartLegendLegendSelectAll", "chartLegendLegendInverseSelect", "chartLegendScroll", "chartDataZoom", "chartDataRangeSelected", "chartGraphRoam", "chartGeoRoam", "chartTreeRoam", "chartTimelineChanged", "chartTimelinePlayChanged", "chartRestore", "chartDataViewChanged", "chartMagicTypeChanged", "chartGeoSelectChanged", "chartGeoSelected", "chartGeoUnselected", "chartAxisAreaSelected", "chartBrush", "chartBrushEnd", "chartBrushSelected", "chartGlobalCursorTaken", "chartRendered", "chartFinished"], exportAs: ["echarts"] }] });
|
|
@@ -2087,6 +2267,146 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
2087
2267
|
], providers: [provideVSEcharts()], template: "<div class=\"echarts-container\" echarts \n [options]=\"{}\"\n [initOpts]=\"initOptions\" \n [autoResize]=\"true\" \n (chartInit)=\"onChartInit($event)\" \n (chartClick)=\"onChartClick($event)\" \n (chartSelectChanged)=\"onChartSelectChanged($event)\"\n></div>\n", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"] }]
|
|
2088
2268
|
}], ctorParameters: () => [] });
|
|
2089
2269
|
|
|
2270
|
+
class SunburstBuilder {
|
|
2271
|
+
baseProduct;
|
|
2272
|
+
valueFormatter = (value) => value.toLocaleString();
|
|
2273
|
+
palette = [];
|
|
2274
|
+
// TODO: Hay que implementar un valor por defecto.
|
|
2275
|
+
colorResolver;
|
|
2276
|
+
result = {};
|
|
2277
|
+
constructor(baseProduct) {
|
|
2278
|
+
this.baseProduct = baseProduct;
|
|
2279
|
+
}
|
|
2280
|
+
reset() {
|
|
2281
|
+
this.result = {};
|
|
2282
|
+
}
|
|
2283
|
+
addSeries(data, overrides) {
|
|
2284
|
+
if (!data || !data.series || data.series.length === 0) {
|
|
2285
|
+
return;
|
|
2286
|
+
}
|
|
2287
|
+
const sunburstData = mapHierarchicalData(data.categories, data.series);
|
|
2288
|
+
const depth = getTreeDepth(sunburstData);
|
|
2289
|
+
const levels = [];
|
|
2290
|
+
for (let i = 0; i <= depth; i++) {
|
|
2291
|
+
levels.push({
|
|
2292
|
+
label: {
|
|
2293
|
+
show: false,
|
|
2294
|
+
},
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
const dynamiSerieOptions = {
|
|
2298
|
+
name: '',
|
|
2299
|
+
data: sunburstData,
|
|
2300
|
+
levels: levels
|
|
2301
|
+
};
|
|
2302
|
+
const serie = merge$1({}, dynamiSerieOptions, overrides);
|
|
2303
|
+
if (this.colorResolver) {
|
|
2304
|
+
if (!serie.itemStyle) {
|
|
2305
|
+
serie.itemStyle = {};
|
|
2306
|
+
}
|
|
2307
|
+
serie.itemStyle.color = this.colorResolver;
|
|
2308
|
+
}
|
|
2309
|
+
this.result.series = serie;
|
|
2310
|
+
}
|
|
2311
|
+
addTooltip(data, overrides) {
|
|
2312
|
+
merge$1(overrides, {
|
|
2313
|
+
formatter: getTooltipFormatter(overrides.trigger || 'item', data, this.valueFormatter),
|
|
2314
|
+
});
|
|
2315
|
+
const tooltip = getTooltipOptions(overrides);
|
|
2316
|
+
this.result.tooltip = tooltip;
|
|
2317
|
+
}
|
|
2318
|
+
addPolar() { }
|
|
2319
|
+
addXAxis(data, overrides, type) { }
|
|
2320
|
+
addYAxis(data, overrides, type) { }
|
|
2321
|
+
addRadiusAxis(data, overrides) { }
|
|
2322
|
+
addAngleAxis(data, overrides) { }
|
|
2323
|
+
addLegend() { }
|
|
2324
|
+
addCommons() {
|
|
2325
|
+
const opts = {
|
|
2326
|
+
palette: this.palette,
|
|
2327
|
+
};
|
|
2328
|
+
merge$1(this.result, getCommons(opts));
|
|
2329
|
+
}
|
|
2330
|
+
addGraphic() { }
|
|
2331
|
+
getResult() {
|
|
2332
|
+
return this.result;
|
|
2333
|
+
}
|
|
2334
|
+
;
|
|
2335
|
+
// Setters
|
|
2336
|
+
/**
|
|
2337
|
+
* Permite inyectar un formateador de valores externo.
|
|
2338
|
+
*/
|
|
2339
|
+
setValueFormatter(formatter) {
|
|
2340
|
+
if (formatter) {
|
|
2341
|
+
this.valueFormatter = formatter;
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
/**
|
|
2345
|
+
* Permite inyectar una paleta de colores básica.
|
|
2346
|
+
*/
|
|
2347
|
+
setPalette(palette) {
|
|
2348
|
+
if (palette) {
|
|
2349
|
+
this.palette = palette;
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
/**
|
|
2353
|
+
* Permite inyectar un resolver de colores dinámico.
|
|
2354
|
+
*/
|
|
2355
|
+
setColorResolver(resolver) {
|
|
2356
|
+
if (resolver) {
|
|
2357
|
+
this.colorResolver = resolver;
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
2361
|
+
|
|
2362
|
+
class EChartsSunburstComponent extends BaseEchartsComponent {
|
|
2363
|
+
baseSeriesOptions = {
|
|
2364
|
+
type: 'sunburst',
|
|
2365
|
+
radius: ['15%', '85%'],
|
|
2366
|
+
sort: undefined,
|
|
2367
|
+
emphasis: {
|
|
2368
|
+
focus: 'ancestor'
|
|
2369
|
+
},
|
|
2370
|
+
itemStyle: {
|
|
2371
|
+
borderWidth: 1.5,
|
|
2372
|
+
borderColor: '#fff'
|
|
2373
|
+
},
|
|
2374
|
+
levels: [
|
|
2375
|
+
{},
|
|
2376
|
+
{
|
|
2377
|
+
label: {
|
|
2378
|
+
rotate: 'tangential'
|
|
2379
|
+
}
|
|
2380
|
+
},
|
|
2381
|
+
]
|
|
2382
|
+
};
|
|
2383
|
+
baseProduct = {
|
|
2384
|
+
chartKey: 'sunburst',
|
|
2385
|
+
baseOptions: {
|
|
2386
|
+
series: this.baseSeriesOptions,
|
|
2387
|
+
},
|
|
2388
|
+
};
|
|
2389
|
+
builder = new SunburstBuilder(this.baseProduct);
|
|
2390
|
+
director = new VSECDirector(this.builder);
|
|
2391
|
+
make() {
|
|
2392
|
+
const makeOpts = {
|
|
2393
|
+
palette: this.palette,
|
|
2394
|
+
colorResolver: this.colorResolver,
|
|
2395
|
+
valueFormatter: this.valueFormatter,
|
|
2396
|
+
};
|
|
2397
|
+
this.director.makeSunburst(this.data, this.optionsOverrides, makeOpts);
|
|
2398
|
+
}
|
|
2399
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EChartsSunburstComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
2400
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: EChartsSunburstComponent, isStandalone: true, selector: "vs-echarts-sunburst", providers: [provideVSEcharts()], usesInheritance: true, ngImport: i0, template: "<div\n class=\"echarts-container\"\n echarts\n [options]=\"{}\"\n [initOpts]=\"initOptions\"\n [autoResize]=\"true\"\n (chartInit)=\"onChartInit($event)\"\n (chartClick)=\"onChartClick($event)\"\n (chartSelectChanged)=\"onChartSelectChanged($event)\"\n></div>", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: NgxEchartsDirective, selector: "echarts, [echarts]", inputs: ["options", "theme", "initOpts", "merge", "autoResize", "loading", "loadingType", "loadingOpts"], outputs: ["chartInit", "optionsError", "chartClick", "chartDblClick", "chartMouseDown", "chartMouseMove", "chartMouseUp", "chartMouseOver", "chartMouseOut", "chartGlobalOut", "chartContextMenu", "chartHighlight", "chartDownplay", "chartSelectChanged", "chartLegendSelectChanged", "chartLegendSelected", "chartLegendUnselected", "chartLegendLegendSelectAll", "chartLegendLegendInverseSelect", "chartLegendScroll", "chartDataZoom", "chartDataRangeSelected", "chartGraphRoam", "chartGeoRoam", "chartTreeRoam", "chartTimelineChanged", "chartTimelinePlayChanged", "chartRestore", "chartDataViewChanged", "chartMagicTypeChanged", "chartGeoSelectChanged", "chartGeoSelected", "chartGeoUnselected", "chartAxisAreaSelected", "chartBrush", "chartBrushEnd", "chartBrushSelected", "chartGlobalCursorTaken", "chartRendered", "chartFinished"], exportAs: ["echarts"] }] });
|
|
2401
|
+
}
|
|
2402
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EChartsSunburstComponent, decorators: [{
|
|
2403
|
+
type: Component,
|
|
2404
|
+
args: [{ selector: 'vs-echarts-sunburst', standalone: true, imports: [
|
|
2405
|
+
CommonModule,
|
|
2406
|
+
NgxEchartsDirective,
|
|
2407
|
+
], providers: [provideVSEcharts()], template: "<div\n class=\"echarts-container\"\n echarts\n [options]=\"{}\"\n [initOpts]=\"initOptions\"\n [autoResize]=\"true\"\n (chartInit)=\"onChartInit($event)\"\n (chartClick)=\"onChartClick($event)\"\n (chartSelectChanged)=\"onChartSelectChanged($event)\"\n></div>", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"] }]
|
|
2408
|
+
}] });
|
|
2409
|
+
|
|
2090
2410
|
// Interfaces de Inputs de Base EChart Component //
|
|
2091
2411
|
|
|
2092
2412
|
;
|
|
@@ -2101,5 +2421,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
2101
2421
|
* Generated bundle index. Do not edit.
|
|
2102
2422
|
*/
|
|
2103
2423
|
|
|
2104
|
-
export { BaseEchartsComponent, EChartsAreaComponent, EChartsAreaStackComponent, EChartsBarStackedComponent, EChartsBarStackedRadialComponent, EChartsHBarComponent, EChartsHBarStackedComponent, EchartsBarComponent, EchartsFunnelComponent, EchartsLineComponent, EchartsPieComponent, EchartsRingComponent, EchartsScatterComponent, defaultOptionsOverrides, initializeEcharts, provideVSEcharts };
|
|
2424
|
+
export { BaseEchartsComponent, EChartsAreaComponent, EChartsAreaStackComponent, EChartsBarStackedComponent, EChartsBarStackedRadialComponent, EChartsHBarComponent, EChartsHBarStackedComponent, EChartsSunburstComponent, EchartsBarComponent, EchartsFunnelComponent, EchartsLineComponent, EchartsPieComponent, EchartsRingComponent, EchartsScatterComponent, defaultOptionsOverrides, initializeEcharts, provideVSEcharts };
|
|
2105
2425
|
//# sourceMappingURL=visionaris-bruno-vs-echarts.mjs.map
|