@visionaris-bruno/vs-echarts 9.0.7 → 9.1.0
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,7 +1,7 @@
|
|
|
1
1
|
import { provideEchartsCore, NgxEchartsDirective } from 'ngx-echarts';
|
|
2
2
|
import * as echarts from 'echarts/core';
|
|
3
|
-
import { BarChart, PieChart, LineChart, ScatterChart, FunnelChart, SunburstChart, SankeyChart, BoxplotChart } from 'echarts/charts';
|
|
4
|
-
import { TooltipComponent, GridComponent, LegendComponent, GraphicComponent, PolarComponent, DatasetComponent, DataZoomComponent } from 'echarts/components';
|
|
3
|
+
import { BarChart, PieChart, LineChart, ScatterChart, FunnelChart, SunburstChart, SankeyChart, BoxplotChart, HeatmapChart } from 'echarts/charts';
|
|
4
|
+
import { TooltipComponent, GridComponent, CalendarComponent, LegendComponent, GraphicComponent, PolarComponent, DatasetComponent, DataZoomComponent, VisualMapComponent } from 'echarts/components';
|
|
5
5
|
import { CanvasRenderer, SVGRenderer } from 'echarts/renderers';
|
|
6
6
|
import * as i0 from '@angular/core';
|
|
7
7
|
import { InjectionToken, Inject, Injectable, EventEmitter, inject, Output, Input, ViewChild, Directive, Component } from '@angular/core';
|
|
@@ -78,6 +78,8 @@ function initializeEcharts() {
|
|
|
78
78
|
BoxplotChart,
|
|
79
79
|
TooltipComponent,
|
|
80
80
|
GridComponent,
|
|
81
|
+
HeatmapChart,
|
|
82
|
+
CalendarComponent,
|
|
81
83
|
LegendComponent,
|
|
82
84
|
CanvasRenderer,
|
|
83
85
|
SVGRenderer,
|
|
@@ -85,6 +87,7 @@ function initializeEcharts() {
|
|
|
85
87
|
PolarComponent,
|
|
86
88
|
DatasetComponent,
|
|
87
89
|
DataZoomComponent,
|
|
90
|
+
VisualMapComponent,
|
|
88
91
|
]);
|
|
89
92
|
// Register additional locales in ECharts
|
|
90
93
|
echarts.registerLocale('ES', langES);
|
|
@@ -183,6 +186,9 @@ function defaultOptionsOverrides() {
|
|
|
183
186
|
hBoxplot: {
|
|
184
187
|
series: {}
|
|
185
188
|
},
|
|
189
|
+
heatmapCalendar: {
|
|
190
|
+
series: {},
|
|
191
|
+
},
|
|
186
192
|
};
|
|
187
193
|
}
|
|
188
194
|
const defaultValueFormatter = (value) => `${value}`;
|
|
@@ -247,6 +253,7 @@ class BaseEchartsComponent {
|
|
|
247
253
|
/** Subject para debouncing de actualizaciones. ReplaySubject asegura no perder el primer renderizado. */
|
|
248
254
|
updateSubject = new ReplaySubject(1);
|
|
249
255
|
updateSubscription;
|
|
256
|
+
afterSetOptionsHook;
|
|
250
257
|
chartInstance;
|
|
251
258
|
vsEchartsConfig = (() => {
|
|
252
259
|
try {
|
|
@@ -290,6 +297,9 @@ class BaseEchartsComponent {
|
|
|
290
297
|
replaceMerge,
|
|
291
298
|
};
|
|
292
299
|
this.chartInstance?.setOption(chartOptions, _opts);
|
|
300
|
+
if (this.afterSetOptionsHook) {
|
|
301
|
+
this.afterSetOptionsHook();
|
|
302
|
+
}
|
|
293
303
|
}
|
|
294
304
|
// metodos protegidos //
|
|
295
305
|
dispatchAction(type, d) {
|
|
@@ -1935,6 +1945,123 @@ class SankeyBuilder {
|
|
|
1935
1945
|
}
|
|
1936
1946
|
}
|
|
1937
1947
|
|
|
1948
|
+
class HeatmapCalendarBuilder {
|
|
1949
|
+
baseProduct;
|
|
1950
|
+
result = {};
|
|
1951
|
+
calendarHeight = 0;
|
|
1952
|
+
valueFormatter = defaultValueFormatter;
|
|
1953
|
+
palette = [];
|
|
1954
|
+
colorResolver;
|
|
1955
|
+
constructor(baseProduct) {
|
|
1956
|
+
this.baseProduct = baseProduct;
|
|
1957
|
+
}
|
|
1958
|
+
reset() {
|
|
1959
|
+
this.result = {};
|
|
1960
|
+
}
|
|
1961
|
+
addCommons() {
|
|
1962
|
+
const opts = {
|
|
1963
|
+
palette: this.palette,
|
|
1964
|
+
};
|
|
1965
|
+
const commonsOverrides = getCommons(opts);
|
|
1966
|
+
merge$1(this.result, commonsOverrides, { grid: {} });
|
|
1967
|
+
}
|
|
1968
|
+
addDataset(data, opts) { }
|
|
1969
|
+
addVisualmap(data) { }
|
|
1970
|
+
addCalendar(data) { }
|
|
1971
|
+
addSeries(data, overrides, opts) {
|
|
1972
|
+
if (!data || !data.dimensions || !data.source || data.source.length === 0)
|
|
1973
|
+
return;
|
|
1974
|
+
const calendarOverrides = opts.calendar;
|
|
1975
|
+
const visualMapOverrides = opts.visualMap;
|
|
1976
|
+
const measureDim = data.dimensions.find(d => d.name !== 'category');
|
|
1977
|
+
const dimKey = measureDim ? measureDim.name : '';
|
|
1978
|
+
const dataByYear = new Map();
|
|
1979
|
+
let min = Infinity;
|
|
1980
|
+
let max = -Infinity;
|
|
1981
|
+
data.source.forEach((s) => {
|
|
1982
|
+
if (!s.category)
|
|
1983
|
+
return;
|
|
1984
|
+
const dateObj = new Date(s.category);
|
|
1985
|
+
if (isNaN(dateObj.getTime()))
|
|
1986
|
+
return;
|
|
1987
|
+
const year = dateObj.getFullYear().toString();
|
|
1988
|
+
const value = s[dimKey] !== undefined && s[dimKey] !== null ? Number(s[dimKey]) : 0;
|
|
1989
|
+
if (value < min)
|
|
1990
|
+
min = value;
|
|
1991
|
+
if (value > max)
|
|
1992
|
+
max = value;
|
|
1993
|
+
if (!dataByYear.has(year)) {
|
|
1994
|
+
dataByYear.set(year, []);
|
|
1995
|
+
}
|
|
1996
|
+
const formattedDate = dateObj.toISOString().split('T')[0];
|
|
1997
|
+
dataByYear.get(year).push([formattedDate, value]);
|
|
1998
|
+
});
|
|
1999
|
+
if (min === Infinity)
|
|
2000
|
+
min = 0;
|
|
2001
|
+
if (max === -Infinity)
|
|
2002
|
+
max = 0;
|
|
2003
|
+
const sortedYears = Array.from(dataByYear.keys()).sort();
|
|
2004
|
+
const calendars = [];
|
|
2005
|
+
const series = [];
|
|
2006
|
+
sortedYears.forEach((year, index) => {
|
|
2007
|
+
calendars.push(merge$1({
|
|
2008
|
+
top: 120 + index * 180,
|
|
2009
|
+
range: year,
|
|
2010
|
+
}, calendarOverrides));
|
|
2011
|
+
series.push(merge$1({
|
|
2012
|
+
calendarIndex: index,
|
|
2013
|
+
data: dataByYear.get(year) || []
|
|
2014
|
+
}, overrides));
|
|
2015
|
+
});
|
|
2016
|
+
this.result.calendar = calendars;
|
|
2017
|
+
this.result.series = series;
|
|
2018
|
+
const visualMap = merge$1({
|
|
2019
|
+
min: min,
|
|
2020
|
+
max: max,
|
|
2021
|
+
}, visualMapOverrides);
|
|
2022
|
+
if (this.palette && this.palette.length > 0) {
|
|
2023
|
+
visualMap.inRange = {
|
|
2024
|
+
color: this.palette
|
|
2025
|
+
};
|
|
2026
|
+
}
|
|
2027
|
+
this.result.visualMap = visualMap;
|
|
2028
|
+
}
|
|
2029
|
+
addTooltip(data, overrides) {
|
|
2030
|
+
const mainDim = data.dimensions.filter(d => d.name != 'category')[0];
|
|
2031
|
+
const valueFormatter = this.valueFormatter;
|
|
2032
|
+
const dimkey = mainDim.name, dimAlias = mainDim.displayName;
|
|
2033
|
+
const tooltipFormatter = (params) => {
|
|
2034
|
+
const date = params.value[params.encode['time']], value = params.value[params.encode['value']];
|
|
2035
|
+
return `<div style="text-align: center;" ><b>${date}</b></br>${params.marker} ${mainDim.displayName}</br><b>${valueFormatter(value, dimkey)}</b></div>`;
|
|
2036
|
+
};
|
|
2037
|
+
const tooltipOptions = getTooltipOptions({
|
|
2038
|
+
trigger: 'item',
|
|
2039
|
+
formatter: tooltipFormatter,
|
|
2040
|
+
});
|
|
2041
|
+
this.result.tooltip = tooltipOptions;
|
|
2042
|
+
}
|
|
2043
|
+
addPolar() { }
|
|
2044
|
+
addXAxis(data, overrides, type) { }
|
|
2045
|
+
addYAxis(data, overrides, type) { }
|
|
2046
|
+
addRadiusAxis(data, overrides) { }
|
|
2047
|
+
addAngleAxis(data, overrides) { }
|
|
2048
|
+
addLegend() { }
|
|
2049
|
+
addGraphic() { }
|
|
2050
|
+
addDataZoom() { }
|
|
2051
|
+
setValueFormatter(formatter) {
|
|
2052
|
+
this.valueFormatter = formatter;
|
|
2053
|
+
}
|
|
2054
|
+
setPalette(palette) {
|
|
2055
|
+
this.palette = palette;
|
|
2056
|
+
}
|
|
2057
|
+
setColorResolver(resolver) {
|
|
2058
|
+
this.colorResolver = resolver;
|
|
2059
|
+
}
|
|
2060
|
+
getResult() {
|
|
2061
|
+
return this.result;
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
|
|
1938
2065
|
/**
|
|
1939
2066
|
* Director de Builds.
|
|
1940
2067
|
*/
|
|
@@ -2206,6 +2333,30 @@ class VSECDirector {
|
|
|
2206
2333
|
this.builder.addTooltip(data, overrides.tooltip);
|
|
2207
2334
|
this.builder.addDataZoom();
|
|
2208
2335
|
}
|
|
2336
|
+
makeHeatmapCalendar(data, overrides, opts = {}) {
|
|
2337
|
+
if (this.builder instanceof HeatmapCalendarBuilder == false) {
|
|
2338
|
+
return;
|
|
2339
|
+
}
|
|
2340
|
+
const { valueFormatter = undefined, palette = undefined, colorResolver = undefined, axisTypes = {
|
|
2341
|
+
x: 'value',
|
|
2342
|
+
y: 'category',
|
|
2343
|
+
}, } = opts;
|
|
2344
|
+
this.builder.reset();
|
|
2345
|
+
// El orden importa, primero callbacks y despues componentes.
|
|
2346
|
+
// chart callbaks
|
|
2347
|
+
if (valueFormatter)
|
|
2348
|
+
this.builder.setValueFormatter(valueFormatter);
|
|
2349
|
+
const product = this.builder.baseProduct;
|
|
2350
|
+
const seriesOverrides = merge$1({}, product.baseOptions.series, overrides[product.chartKey].series);
|
|
2351
|
+
// chart components
|
|
2352
|
+
this.builder.addCommons();
|
|
2353
|
+
const seriesConfigOpts = {
|
|
2354
|
+
calendar: product.baseOptions.calendar,
|
|
2355
|
+
visualMap: product.baseOptions.visualMap,
|
|
2356
|
+
};
|
|
2357
|
+
this.builder.addSeries(data, seriesOverrides, seriesConfigOpts);
|
|
2358
|
+
this.builder.addTooltip(data, overrides.tooltip);
|
|
2359
|
+
}
|
|
2209
2360
|
}
|
|
2210
2361
|
|
|
2211
2362
|
/**
|
|
@@ -3008,6 +3159,104 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
3008
3159
|
], template: "<div\n class=\"echarts-container\"\n echarts\n [options]=\"{}\"\n [initOpts]=\"initOptions\"\n [autoResize]=\"true\"\n (chartInit)=\"onChartInit($event)\"\n></div>\n", styles: [".echarts-container{width:100%;height:100%;position:relative}\n"] }]
|
|
3009
3160
|
}] });
|
|
3010
3161
|
|
|
3162
|
+
class EChartsHeatmapCalendar extends BaseEchartsComponent {
|
|
3163
|
+
/** aires para el calculo de resize y posicionamientos de distintos componentes */
|
|
3164
|
+
calendarPaddings = {
|
|
3165
|
+
visualMapTop: 5,
|
|
3166
|
+
};
|
|
3167
|
+
baseSeriesOptions = {
|
|
3168
|
+
type: 'heatmap',
|
|
3169
|
+
coordinateSystem: 'calendar',
|
|
3170
|
+
selectedMode: 'single',
|
|
3171
|
+
select: {
|
|
3172
|
+
itemStyle: {
|
|
3173
|
+
borderWidth: 2,
|
|
3174
|
+
borderColor: EChartsTokens.sBorderColor,
|
|
3175
|
+
shadowColor: EChartsTokens.sShadowColor,
|
|
3176
|
+
shadowBlur: 6,
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
};
|
|
3180
|
+
baseProduct = {
|
|
3181
|
+
chartKey: 'heatmapCalendar',
|
|
3182
|
+
baseOptions: {
|
|
3183
|
+
visualMap: {
|
|
3184
|
+
calculable: true,
|
|
3185
|
+
orient: 'horizontal',
|
|
3186
|
+
left: 'center',
|
|
3187
|
+
top: this.calendarPaddings.visualMapTop,
|
|
3188
|
+
formatter: (dv) => {
|
|
3189
|
+
const value = dv ?? '';
|
|
3190
|
+
return value.toLocaleString();
|
|
3191
|
+
},
|
|
3192
|
+
}, // dinamico
|
|
3193
|
+
calendar: {
|
|
3194
|
+
cellSize: ['auto', 20],
|
|
3195
|
+
right: 5,
|
|
3196
|
+
left: 60,
|
|
3197
|
+
yearLabel: { show: true },
|
|
3198
|
+
dayLabel: { firstDay: 1 },
|
|
3199
|
+
},
|
|
3200
|
+
series: this.baseSeriesOptions, // dinamico, uno por año.
|
|
3201
|
+
}
|
|
3202
|
+
};
|
|
3203
|
+
builder = new HeatmapCalendarBuilder(this.baseProduct);
|
|
3204
|
+
director = new VSECDirector(this.builder);
|
|
3205
|
+
make() {
|
|
3206
|
+
const makeOpts = {
|
|
3207
|
+
palette: this.palette,
|
|
3208
|
+
valueFormatter: this.valueFormatter,
|
|
3209
|
+
colorResolver: this.colorResolver,
|
|
3210
|
+
};
|
|
3211
|
+
this.director.makeHeatmapCalendar(this.data, this.optionsOverrides, makeOpts);
|
|
3212
|
+
}
|
|
3213
|
+
afterSetOptionsHook = () => {
|
|
3214
|
+
if (!this.chartInstance)
|
|
3215
|
+
return;
|
|
3216
|
+
let chartHeight = 0;
|
|
3217
|
+
const gElements = this.chartInstance.getDom().getElementsByTagName("g");
|
|
3218
|
+
for (let i = 0; i < gElements.length; i++) {
|
|
3219
|
+
const ge = gElements[i];
|
|
3220
|
+
const geHeight = ge.getBBox().height;
|
|
3221
|
+
if (chartHeight < geHeight) {
|
|
3222
|
+
chartHeight = geHeight;
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
const { visualMapTop } = this.calendarPaddings;
|
|
3226
|
+
/**
|
|
3227
|
+
* aire inferior para el svg maestro.
|
|
3228
|
+
*/
|
|
3229
|
+
const svgBottom = 5;
|
|
3230
|
+
this.chartInstance.resize({ height: chartHeight + visualMapTop + svgBottom });
|
|
3231
|
+
};
|
|
3232
|
+
onChartClick(event) {
|
|
3233
|
+
if (event.componentType === 'series') {
|
|
3234
|
+
const dimension = this.data.dimensions.filter(d => d.name != 'category')[0];
|
|
3235
|
+
const dimensionAlias = dimension.displayName;
|
|
3236
|
+
const dimensionKey = dimension.name;
|
|
3237
|
+
const itemValue = event.value[event.encode['value']];
|
|
3238
|
+
const date = event.value[event.encode['time']];
|
|
3239
|
+
// opero event para que sea compatible con el de base
|
|
3240
|
+
event.value = {
|
|
3241
|
+
category: date,
|
|
3242
|
+
[dimensionKey]: itemValue,
|
|
3243
|
+
};
|
|
3244
|
+
event.name = date;
|
|
3245
|
+
event.seriesName = dimensionAlias;
|
|
3246
|
+
super.onChartClick(event);
|
|
3247
|
+
}
|
|
3248
|
+
}
|
|
3249
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EChartsHeatmapCalendar, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
3250
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.19", type: EChartsHeatmapCalendar, isStandalone: true, selector: "vs-echarts-heatmapCalendar", 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;overflow-y:auto;scrollbar-gutter:stable}\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"] }] });
|
|
3251
|
+
}
|
|
3252
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: EChartsHeatmapCalendar, decorators: [{
|
|
3253
|
+
type: Component,
|
|
3254
|
+
args: [{ selector: 'vs-echarts-heatmapCalendar', standalone: true, imports: [
|
|
3255
|
+
CommonModule,
|
|
3256
|
+
NgxEchartsDirective,
|
|
3257
|
+
], 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;overflow-y:auto;scrollbar-gutter:stable}\n"] }]
|
|
3258
|
+
}] });
|
|
3259
|
+
|
|
3011
3260
|
// Interfaces de Inputs de Base EChart Component //
|
|
3012
3261
|
// TopLevelFormatterParams
|
|
3013
3262
|
|
|
@@ -3023,5 +3272,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImpo
|
|
|
3023
3272
|
* Generated bundle index. Do not edit.
|
|
3024
3273
|
*/
|
|
3025
3274
|
|
|
3026
|
-
export { BaseEchartsComponent, EChartsAreaComponent, EChartsAreaStackComponent, EChartsBarStackedComponent, EChartsBarStackedRadialComponent, EChartsHBarComponent, EChartsHBarStackedComponent, EChartsHBoxplotComponent, EChartsSunburstComponent, EchartsBarComponent, EchartsFunnelComponent, EchartsLineComponent, EchartsPieComponent, EchartsRingComponent, EchartsSankeyComponent, EchartsScatterComponent, VSEchartsConfigService, defaultOptionsOverrides, provideVSEcharts };
|
|
3275
|
+
export { BaseEchartsComponent, EChartsAreaComponent, EChartsAreaStackComponent, EChartsBarStackedComponent, EChartsBarStackedRadialComponent, EChartsHBarComponent, EChartsHBarStackedComponent, EChartsHBoxplotComponent, EChartsHeatmapCalendar, EChartsSunburstComponent, EchartsBarComponent, EchartsFunnelComponent, EchartsLineComponent, EchartsPieComponent, EchartsRingComponent, EchartsSankeyComponent, EchartsScatterComponent, VSEchartsConfigService, defaultOptionsOverrides, provideVSEcharts };
|
|
3027
3276
|
//# sourceMappingURL=visionaris-bruno-vs-echarts.mjs.map
|