UNPKG

@senx/discovery-widgets

Version:

Discovery Widgets Elements

1,194 lines (1,193 loc) 51.9 kB
/* * Copyright 2022-2025 SenX S.A.S. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { h, Host } from "@stencil/core"; import { DataModel } from "../../model/types"; import { Param } from "../../model/param"; import { graphic, init } from "echarts"; import { Logger } from "../../utils/logger"; import { GTSLib } from "../../utils/gts.lib"; import { Utils } from "../../utils/utils"; import { ColorLib } from "../../utils/color-lib"; import { v4 } from "uuid"; import _ from "lodash"; export class DiscoveryAnnotation { constructor() { this.options = new Param(); this.debug = false; this.language = 'warpscript'; this.vars = '{}'; this.parsing = false; this.rendering = false; this.expanded = false; this.defOptions = Object.assign(Object.assign({}, new Param()), { timeMode: 'date' }); this.displayExpander = false; this.divider = 1000; this.hasFocus = false; this.gtsList = []; this.leftMargin = 0; this.MAX_MARGIN = 1024; this.pois = []; this.innerVars = {}; this.restoreZoomHandler = _.throttle(() => { this.dataZoom.emit({ type: 'restore' }); }, 100, { 'trailing': false }); } static renderItem(params, api) { const y = +api.value(0); const start = api.coord([+api.value(1), y]); const height = api.size([0, 1])[1]; const width = 1; const coordSys = params.coordSys; const rectShape = graphic.clipRectByRect({ x: start[0], y: start[1] - height / 2, width, height }, { x: coordSys.x, y: coordSys.y, width: coordSys.width, height: coordSys.height }); return (rectShape && { type: 'rect', transition: ['shape'], shape: rectShape, style: api.style(), }); } ; varsUpdate(newValue, oldValue) { var _a; let vars = this.vars; if (!!this.vars && typeof this.vars === 'string') { vars = JSON.parse(this.vars); } if (!Utils.deepEqual(vars, this.innerVars)) { this.innerVars = Utils.clone(vars); } (_a = this.LOG) === null || _a === void 0 ? void 0 : _a.debug(['varsUpdate'], { vars: this.vars, newValue, oldValue }); } updateRes() { var _a; this.chartOpts = this.convert((_a = GTSLib.getData(this.result)) !== null && _a !== void 0 ? _a : new DataModel()); if (this.myChart) { setTimeout(() => this.setOpts(true)); } } optionsUpdate(newValue, oldValue) { var _a, _b, _c; (_a = this.LOG) === null || _a === void 0 ? void 0 : _a.debug(['optionsUpdate'], newValue, oldValue); let opts = newValue; if (!!newValue && typeof newValue === 'string') { opts = JSON.parse(newValue); } if (!Utils.deepEqual(opts, this.innerOptions)) { this.innerOptions = Utils.clone(opts); if (this.myChart) { this.chartOpts = this.convert((_b = this.result) !== null && _b !== void 0 ? _b : new DataModel()); setTimeout(() => this.setOpts(true)); } (_c = this.LOG) === null || _c === void 0 ? void 0 : _c.debug(['optionsUpdate 2'], { options: this.innerOptions, newValue, oldValue }, this.chartOpts); } } async resize() { this.myChart.resize({ width: this.width, height: this.height }); return Promise.resolve(); } async show(regexp) { this.myChart.dispatchAction({ type: 'legendSelect', batch: this.myChart.getOption().series .filter(s => new RegExp(regexp).test(GTSLib.getName(s.name))), }); return Promise.resolve(); } async hide(regexp) { this.myChart.dispatchAction({ type: 'legendUnSelect', batch: this.myChart.getOption().series .filter(s => new RegExp(regexp).test(GTSLib.getName(s.name))), }); return Promise.resolve(); } async hideById(id) { if (this.myChart) { this.myChart.dispatchAction({ type: 'legendUnSelect', batch: this.myChart.getOption().series .filter((s, i) => { var _a; return new RegExp(id.toString()).test(((_a = s.id) !== null && _a !== void 0 ? _a : i).toString()); }), }); } return Promise.resolve(); } async showById(id) { if (this.myChart) { this.myChart.dispatchAction({ type: 'legendSelect', batch: this.myChart.getOption().series .filter((s, i) => { var _a; return new RegExp(id.toString()).test(((_a = s.id) !== null && _a !== void 0 ? _a : i).toString()); }), }); } return Promise.resolve(); } // noinspection JSUnusedGlobalSymbols componentWillLoad() { var _a, _b, _c; this.parsing = true; this.LOG = new Logger(DiscoveryAnnotation, this.debug); if (typeof this.options === 'string') { this.innerOptions = JSON.parse(this.options); } else { this.innerOptions = this.options; } this.expanded = !!this.innerOptions.expandAnnotation; this.result = GTSLib.getData(this.result); this.divider = GTSLib.getDivider((_a = this.innerOptions.timeUnit) !== null && _a !== void 0 ? _a : 'us'); (_b = this.LOG) === null || _b === void 0 ? void 0 : _b.debug(['componentWillLoad'], { type: this.type, options: this.innerOptions }); this.chartOpts = this.convert((_c = this.result) !== null && _c !== void 0 ? _c : new DataModel()); this.setOpts(); } setOpts(notMerge = false) { var _a, _b, _c, _d; if (!!this.vars && typeof this.vars === 'string') { this.innerVars = JSON.parse(this.vars); } else if (this.vars) { this.innerVars = this.vars; } if (((_b = (_a = this.chartOpts) === null || _a === void 0 ? void 0 : _a.series) !== null && _b !== void 0 ? _b : []).length === 0) { this.chartOpts.title = { show: true, textStyle: { color: Utils.getLabelColor(this.el), fontSize: 20 }, text: (_c = this.innerOptions.noDataLabel) !== null && _c !== void 0 ? _c : '', left: 'center', top: 'center', }; this.chartOpts.xAxis = { show: false }; this.chartOpts.yAxis = { show: false }; this.chartOpts.tooltip = { show: false }; } else { this.chartOpts.title = Object.assign(Object.assign({}, (_d = this.chartOpts.title) !== null && _d !== void 0 ? _d : {}), { show: false }); } setTimeout(() => { var _a; if (this.myChart) { this.myChart.setOption((_a = this.chartOpts) !== null && _a !== void 0 ? _a : {}, notMerge, true); this.myChart.resize({ width: this.width, height: this.height }); } }); } convert(data) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v; let options = Utils.mergeDeep(this.defOptions, (_a = this.innerOptions) !== null && _a !== void 0 ? _a : {}); options = Utils.mergeDeep(options, (_b = data.globalParams) !== null && _b !== void 0 ? _b : {}); this.innerOptions = Utils.clone(Object.assign(Object.assign({}, options), { leftMargin: this.innerOptions.leftMargin })); this.innerOptions.timeMode = (_c = this.innerOptions.timeMode) !== null && _c !== void 0 ? _c : 'date'; const series = []; const categories = []; const gtsList = GTSLib.flatDeep(GTSLib.flattenGtsIdArray(data.data, 0).res); this.gtsList = []; (_d = this.LOG) === null || _d === void 0 ? void 0 : _d.debug(['convert'], { options: this.innerOptions, gtsList }); const gtsCount = gtsList.length; let linesCount = 1; let catId = 0; let min = Number.MAX_SAFE_INTEGER; let max = Number.MIN_SAFE_INTEGER; let hasTimeBounds = false; if (max <= 1000 && min >= -1000 && min !== Number.MAX_SAFE_INTEGER && max !== Number.MIN_SAFE_INTEGER) { this.innerOptions.timeMode = 'timestamp'; } for (let i = 0; i < gtsCount; i++) { const gts = gtsList[i]; if (GTSLib.isGtsToAnnotate(gts) && !!gts.v) { this.gtsList.push(gts); const dataSet = []; for (let v = 0; v < ((_e = gts.v) !== null && _e !== void 0 ? _e : []).length; v++) { const tuple = gts.v[v]; const ts = tuple[0]; const val = tuple[tuple.length - 1]; if (ts > max) max = ts; if (ts < min) min = ts; let startTS = ts; startTS = this.innerOptions.timeMode === 'date' ? GTSLib.utcToZonedTime(startTS, this.divider, this.innerOptions.timeZone) : startTS; dataSet.push([catId, startTS, val]); } const c = ColorLib.getColor(gts.id, this.innerOptions.scheme); const color = (_h = (_g = ((_f = data.params) !== null && _f !== void 0 ? _f : [])[i]) === null || _g === void 0 ? void 0 : _g.datasetColor) !== null && _h !== void 0 ? _h : c; const name = (_l = (_k = ((_j = data.params) !== null && _j !== void 0 ? _j : [])[i]) === null || _k === void 0 ? void 0 : _k.key) !== null && _l !== void 0 ? _l : GTSLib.serializeGtsMetadata(gts); if (this.expanded) { linesCount++; categories.push(name); } hasTimeBounds = true; series.push({ type: 'custom', name: GTSLib.setName(gts.id, name), data: dataSet, animation: false, id: gts.id, large: true, clip: false, showAllSymbol: false, renderItem: DiscoveryAnnotation.renderItem.bind(this), itemStyle: { color }, encode: { x: 1, y: 0 }, }); if (this.expanded) catId++; } } this.displayExpander = series.length > 1 && !!this.innerOptions.displayExpander; if (hasTimeBounds) { this.timeBounds.emit({ min, max }); this.bounds = { min, max }; } this.height = 50 + (linesCount * (this.expanded ? 26 : 30)) + (this.innerOptions.showLegend ? 30 : 0) + (this.innerOptions.fullDateDisplay ? 50 : 0); (_m = this.LOG) === null || _m === void 0 ? void 0 : _m.debug(['convert'], { expanded: this.expanded, height: this.height, linesCount, opts: this.innerOptions, }); const opts = Object.assign({ animation: false, grid: { height: this.height - (this.innerOptions.showLegend ? 60 : 30) - (this.innerOptions.fullDateDisplay ? 40 : 0), right: 10, top: 20, bottom: (this.innerOptions.showLegend ? 30 : 10) + (this.innerOptions.fullDateDisplay ? 0 : 0), left: (this.innerOptions.leftMargin !== undefined && this.innerOptions.leftMargin > this.leftMargin) ? this.innerOptions.leftMargin : (_o = this.leftMargin) !== null && _o !== void 0 ? _o : 10, containLabel: true, }, throttle: 70, tooltip: { trigger: 'axis', transitionDuration: 0, formatter: (params) => { var _a; return `<div style="font-size:14px;color:#666;font-weight:400;line-height:1;">${this.innerOptions.timeMode !== 'date' ? params[0].value[1] : ((_a = GTSLib.toISOString(GTSLib.zonedTimeToUtc(params[0].value[1], 1, this.innerOptions.timeZone), 1, this.innerOptions.timeZone, this.innerOptions.timeFormat)) !== null && _a !== void 0 ? _a : '') .replace('T', ' ').replace(/\+[0-9]{2}:[0-9]{2}$/gi, '')}</div> ${params.map(s => { return `${s.marker} <span style="font-size:14px;color:#666;font-weight:400;margin-left:2px">${GTSLib.getName(s.seriesName)}</span> <span style="float:right;margin-left:20px;font-size:14px;color:#666;font-weight:900">${s.value[2]}</span>`; }).join('<br>')}`; }, axisPointer: { axis: 'x', type: 'line', animation: false, lineStyle: { color: Utils.getCSSColor(this.el, '--warp-view-bar-color', 'red'), }, }, backgroundColor: Utils.getCSSColor(this.el, '--warp-view-tooltip-bg-color', 'white'), hideDelay: (_p = this.innerOptions.tooltipDelay) !== null && _p !== void 0 ? _p : 100, position: (pos, params, el, elRect, size) => { var _a, _b, _c, _d; const obj = { top: 10 }; if (this.hasFocus) { const date = this.innerOptions.timeMode === 'date' ? GTSLib.zonedTimeToUtc((_b = (_a = params[0]) === null || _a === void 0 ? void 0 : _a.axisValue) !== null && _b !== void 0 ? _b : 0, 1, this.innerOptions.timeZone) * this.divider : (_d = (_c = params[0]) === null || _c === void 0 ? void 0 : _c.axisValue) !== null && _d !== void 0 ? _d : 0; const regexp = '(' + params.map(s => s.seriesName).join('|') + ')'; if (this.focusDate !== date) { this.dataPointOver.emit({ date, name: regexp, value: params.map(p => p.value[2]), meta: {} }); this.focusDate = date; } } obj[['left', 'right'][+(pos[0] < size.viewSize[0] / 2)]] = 30; return obj; }, }, toolbox: { show: this.innerOptions.showControls, feature: { saveAsImage: { type: 'png', excludeComponents: ['toolbox'] }, restore: { show: true }, }, }, xAxis: { type: this.innerOptions.timeMode === 'date' ? 'time' : 'value', splitNumber: Math.max(Math.floor(Utils.getContentBounds(this.el.parentElement).w / 100) - 1, 1), splitLine: { show: false, lineStyle: { color: Utils.getGridColor(this.el) } }, axisLine: { lineStyle: { color: Utils.getGridColor(this.el) } }, axisLabel: { hideOverlap: true, color: Utils.getLabelColor(this.el), formatter: this.innerOptions.fullDateDisplay ? value => GTSLib.toISOString(GTSLib.zonedTimeToUtc(value, 1, this.innerOptions.timeZone), 1, this.innerOptions.timeZone, this.innerOptions.timeFormat) .replace('T', '\n').replace(/\+[0-9]{2}:[0-9]{2}$/gi, '') : undefined, }, axisTick: { show: true, lineStyle: { color: Utils.getGridColor(this.el) } }, scale: !(this.innerOptions.bounds && (!!this.innerOptions.bounds.minDate || !!this.innerOptions.bounds.maxDate)), min: ((_q = this.innerOptions.bounds) === null || _q === void 0 ? void 0 : _q.minDate) !== undefined ? this.innerOptions.timeMode === 'date' ? GTSLib.utcToZonedTime(this.innerOptions.bounds.minDate, this.divider, this.innerOptions.timeZone) : this.innerOptions.bounds.minDate : undefined, max: ((_r = this.innerOptions.bounds) === null || _r === void 0 ? void 0 : _r.maxDate) !== undefined ? this.innerOptions.timeMode === 'date' ? GTSLib.utcToZonedTime(this.innerOptions.bounds.maxDate, this.divider, this.innerOptions.timeZone) : this.innerOptions.bounds.maxDate : undefined, }, yAxis: { show: true, axisTick: { show: false }, axisLabel: { hideOverlap: true, show: false, }, type: 'category', data: categories.length === 0 ? ['-'] : categories, splitNumber: Math.max(categories.length, 1), interval: 1, boundaryGap: [0, 0], splitLine: { show: true, lineStyle: { color: Utils.getGridColor(this.el) } }, axisLine: { lineStyle: { color: Utils.getGridColor(this.el), }, }, }, legend: { bottom: 0, left: 'center', show: !!this.innerOptions.showLegend, height: 30, type: 'scroll', textStyle: { color: Utils.getLabelColor(this.el) }, formatter: n => GTSLib.getName(n), }, dataZoom: [ this.innerOptions.showRangeSelector ? { type: 'slider', height: '20px', filterMode: 'none', } : undefined, { type: 'inside', filterMode: 'none', }, ], series }, (_u = (_t = (_s = this.innerOptions) === null || _s === void 0 ? void 0 : _s.extra) === null || _t === void 0 ? void 0 : _t.chartOpts) !== null && _u !== void 0 ? _u : {}); ((_v = this.innerOptions.actions) !== null && _v !== void 0 ? _v : []).forEach((action) => { var _a, _b; if (action.macro) { opts.toolbox.feature['my' + v4().replaceAll('-', '')] = { title: (_a = action.title) !== null && _a !== void 0 ? _a : '', show: true, icon: (_b = action.icon) !== null && _b !== void 0 ? _b : Utils.DEFICON, onclick: () => Utils.execAction(action.macro, this), }; } }); return opts; } zoomHandler(start, end) { var _a, _b, _c, _d, _e, _f; this.dataZoom.emit({ start, end, min: (_b = (_a = this.innerOptions.bounds) === null || _a === void 0 ? void 0 : _a.minDate) !== null && _b !== void 0 ? _b : (_c = this.bounds) === null || _c === void 0 ? void 0 : _c.min, max: (_e = (_d = this.innerOptions.bounds) === null || _d === void 0 ? void 0 : _d.maxDate) !== null && _e !== void 0 ? _e : (_f = this.bounds) === null || _f === void 0 ? void 0 : _f.max, }); } // noinspection JSUnusedGlobalSymbols componentDidLoad() { const zoomHandler = _.throttle((start, end) => this.zoomHandler(start, end), 16, { leading: true, trailing: true }); const focusHandler = _.throttle((type, event) => { var _a, _b; if (this.hasFocus) { switch (type) { case 'mouseover': const c = (_a = event.data.coord) !== null && _a !== void 0 ? _a : event.data; this.dataPointSelected.emit({ date: c[0], name: GTSLib.getName(event.seriesName), value: c[1], meta: {}, }); break; case 'highlight': let ts; ((_b = event.batch) !== null && _b !== void 0 ? _b : []).forEach(b => { var _a; const s = this.myChart.getOption().series[b.seriesIndex]; ts = s.data[b.dataIndex][0]; ts = this.innerOptions.timeMode === 'date' ? GTSLib.zonedTimeToUtc(ts * this.divider, this.divider, (_a = this.innerOptions.timeZone) !== null && _a !== void 0 ? _a : 'UTC') * this.divider : ts; }); if (ts !== undefined) { this.dataPointOver.emit({ date: ts, name: '.*', meta: {} }); } break; default: break; } } }, 100, { leading: true, trailing: true }); this.parsing = false; this.rendering = true; let initial = false; this.myChart = init(this.graph, null, { width: this.width, height: this.height, renderer: 'canvas', }); this.myChart.on('rendered', () => { this.rendering = false; let found = false; let x = 0; setTimeout(() => { var _a; while (!found && x < 1024) { found = this.myChart.containPixel({ gridIndex: 0 }, [x, this.myChart.getHeight() / 2]); x++; } if (this.leftMargin !== x && x < ((_a = this.innerOptions.leftMargin) !== null && _a !== void 0 ? _a : this.MAX_MARGIN)) { setTimeout(() => { if (x !== this.MAX_MARGIN) { this.leftMarginComputed.emit(x); this.leftMargin = x; } }); } if (initial) setTimeout(() => this.draw.emit()); initial = false; }); }); this.myChart.on('highlight', (event) => { var _a; let ts; let v; const series = []; ((_a = event.batch) !== null && _a !== void 0 ? _a : []).forEach((b) => { var _a; const s = this.myChart.getOption().series[b.seriesIndex]; ts = s.data[b.dataIndex][0]; ts = this.innerOptions.timeMode === 'date' ? GTSLib.zonedTimeToUtc(ts * this.divider, this.divider, (_a = this.innerOptions.timeZone) !== null && _a !== void 0 ? _a : 'UTC') * this.divider : ts; v = s.data[b.dataIndex][1]; series.push(GTSLib.getName(s.name)); }); if (ts !== undefined) { this.dataPointOver.emit({ date: ts, name: '(' + series.join('|') + ')', value: v, meta: {} }); } }); this.myChart.on('click', (event) => { var _a; const c = (_a = event.data.coord) !== null && _a !== void 0 ? _a : event.data; const date = this.innerOptions.timeMode === 'date' ? GTSLib.zonedTimeToUtc(c[0], 1, this.innerOptions.timeZone) * this.divider : c[0]; if (event.componentType !== 'markLine') { this.dataPointSelected.emit({ date, name: GTSLib.getName(event.seriesName), value: c[2], meta: {} }); } if (this.innerOptions.poi) { if (this.pois.find(p => p.date === c[1])) { this.pois = this.pois.filter(p => p.date !== c[1]); } else if (event.componentType !== 'markLine') { this.pois.push({ date, name: GTSLib.getName(event.seriesName), value: c[2], meta: {}, uid: v4() }); } this.chartOpts.series = this.chartOpts.series.filter(s => 'poi' !== s.id); this.poi.emit(this.pois); this.chartOpts.series.push({ id: 'poi', name: '', type: 'line', data: [], markLine: { emphasis: { lineStyle: { width: 1 } }, symbol: ['none', 'pin'], symbolSize: 20, symbolKeepAspect: true, data: this.pois.map(p => ({ name: 'poi-' + p.uid, label: { show: false }, lineStyle: { color: this.innerOptions.poiColor, type: this.innerOptions.poiLine }, xAxis: this.innerOptions.timeMode === 'date' ? GTSLib.utcToZonedTime(p.date / this.divider, 1, this.innerOptions.timeZone) : p.date, })), }, }); setTimeout(() => { var _a; return this.myChart.setOption((_a = this.chartOpts) !== null && _a !== void 0 ? _a : {}, true, false); }); } }); this.myChart.on('dataZoom', (event) => { var _a, _b, _c, _d; let start; let end; if (event.batch) { const batch = (_b = ((_a = event.batch) !== null && _a !== void 0 ? _a : [])[0]) !== null && _b !== void 0 ? _b : {}; start = (_c = batch.start) !== null && _c !== void 0 ? _c : batch.startValue; end = (_d = batch.end) !== null && _d !== void 0 ? _d : batch.endValue; this.zoomHandler(start, end); } else if (event.start !== undefined && event.end !== undefined) { start = event.start; end = event.end; zoomHandler(start, end); } }); this.myChart.on('restore', () => this.restoreZoomHandler()); this.myChart.on('mouseout', () => { this.dataPointOver.emit({}); }); this.myChart.on('mouseover', (event) => focusHandler('mouseover', event)); this.myChart.on('highlight', (event) => focusHandler('highlight', event)); this.el.addEventListener('dblclick', () => this.myChart.dispatchAction({ type: 'dataZoom', start: 0, end: 100, })); this.el.addEventListener('mouseover', () => this.hasFocus = true); this.el.addEventListener('mouseout', () => { this.hasFocus = false; this.dataPointOver.emit({}); }); initial = true; this.setOpts(); } async setZoom(dataZoom) { if (this.myChart) { if ('restore' === dataZoom.type) { this.myChart.dispatchAction({ type: 'restore' }); } else { this.myChart.dispatchAction(Object.assign(Object.assign({ type: 'dataZoom' }, dataZoom), { dataZoomIndex: 1 })); } } return Promise.resolve(); } async export(type = 'png') { return Promise.resolve(this.myChart ? this.myChart.getDataURL({ type, excludeComponents: ['toolbox'], }) : undefined); } async setFocus(regexp, ts) { var _a; if (!this.myChart || this.gtsList.length === 0 || this.hasFocus) return; if (typeof ts === 'string') ts = parseInt(ts, 10); let ttp = []; const date = this.innerOptions.timeMode === 'date' ? GTSLib.utcToZonedTime(ts !== null && ts !== void 0 ? ts : 0, this.divider, this.innerOptions.timeZone) : ts !== null && ts !== void 0 ? ts : 0; let seriesIndex = 0; let dataIndex = 0; if (regexp) { this.chartOpts.series .filter(s => new RegExp(regexp).test(GTSLib.getName(s.name))) .forEach(s => { seriesIndex = this.chartOpts.series.indexOf(s); const data = s.data.filter(d => d[1] === date); if (data && data[0]) { dataIndex = s.data.indexOf(data[0]); s.markPoint = { symbol: 'rect', symbolSize: [4, 30], data: [{ name: s.name, itemStyle: { color: '#fff', borderColor: s.itemStyle.color, }, yAxis: data[0][0], xAxis: date, }], }; ttp = [date, data[0][0]]; } }); this.myChart.dispatchAction({ type: 'highlight', seriesName: this.chartOpts.series .filter(s => new RegExp(regexp).test(GTSLib.getName(s.name))) .map(s => GTSLib.getName(s.name)), }); } this.chartOpts.xAxis.axisPointer = Object.assign(Object.assign({}, (_a = this.chartOpts.xAxis.axisPointer) !== null && _a !== void 0 ? _a : {}), { value: date, status: 'show' }); this.chartOpts.tooltip.show = true; if (ttp.length > 0) { this.myChart.dispatchAction({ type: 'showTip', dataIndex, seriesIndex }); } else { this.myChart.dispatchAction({ type: 'hideTip' }); } this.setOpts(); return Promise.resolve(); } async unFocus() { var _a, _b; if (!this.myChart || this.hasFocus) return; this.chartOpts.series.forEach(s => s.markPoint = undefined); this.chartOpts.xAxis.axisPointer = Object.assign(Object.assign({}, (_a = this.chartOpts.xAxis.axisPointer) !== null && _a !== void 0 ? _a : {}), { status: 'hide' }); this.chartOpts.yAxis.axisPointer = Object.assign(Object.assign({}, (_b = this.chartOpts.yAxis.axisPointer) !== null && _b !== void 0 ? _b : {}), { status: 'hide' }); this.myChart.dispatchAction({ type: 'hideTip' }); this.setOpts(); return Promise.resolve(); } hideMarkers() { if (!this.myChart) return; this.chartOpts.series.forEach(s => s.markPoint = undefined); this.setOpts(); } render() { return h(Host, { key: '3101deb7b38aa37c7fb795b8b0b556798dd7c687', style: { width: `${this.width}px`, height: `${(this.height + (this.expanded ? 50 : 0))}px` } }, this.displayExpander ? h("button", { class: "expander", onClick: () => this.toggle(), title: "collapse/expand" }, "+/-") : '', h("div", { key: '35d83d22159147157f5286acccc7c3ddc4b8e0bf', class: "chart-area", style: { width: `${this.width}px`, height: `${(this.height + (this.innerOptions.showLegend ? 50 : 0) + (this.innerOptions.fullDateDisplay ? 50 : 0))}px`, } }, this.parsing ? h("div", { class: "discovery-chart-spinner" }, h("discovery-spinner", null, "Parsing data...")) : '', this.rendering ? h("div", { class: "discovery-chart-spinner" }, h("discovery-spinner", null, "Rendering data...")) : '', h("div", { key: 'b9fc9b1152c20f17039bd1ae4a0dc5e28ee29b60', ref: (el) => this.graph = el, onMouseOver: () => this.hideMarkers() }))); } toggle() { var _a; this.expanded = !this.expanded; this.chartOpts = this.convert((_a = this.result) !== null && _a !== void 0 ? _a : new DataModel()); setTimeout(() => { this.myChart.resize({ width: this.width, height: this.height, }); this.setOpts(); }); } static get is() { return "discovery-annotation"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["discovery-annotation.scss"] }; } static get styleUrls() { return { "$": ["discovery-annotation.css"] }; } static get properties() { return { "result": { "type": "string", "mutable": true, "complexType": { "original": "DataModel | string", "resolved": "DataModel | string", "references": { "DataModel": { "location": "import", "path": "../../model/types", "id": "src/model/types.ts::DataModel" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "result", "reflect": false }, "type": { "type": "string", "mutable": false, "complexType": { "original": "ChartType", "resolved": "string", "references": { "ChartType": { "location": "import", "path": "../../model/types", "id": "src/model/types.ts::ChartType" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "type", "reflect": false }, "options": { "type": "string", "mutable": false, "complexType": { "original": "Param | string", "resolved": "Param | string", "references": { "Param": { "location": "import", "path": "../../model/param", "id": "src/model/param.ts::Param" } } }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "options", "reflect": false, "defaultValue": "new Param()" }, "width": { "type": "number", "mutable": false, "complexType": { "original": "number", "resolved": "number", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "width", "reflect": false }, "height": { "type": "number", "mutable": false, "complexType": { "original": "number", "resolved": "number", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "height", "reflect": false }, "debug": { "type": "boolean", "mutable": false, "complexType": { "original": "boolean", "resolved": "boolean", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "debug", "reflect": false, "defaultValue": "false" }, "unit": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "unit", "reflect": false }, "url": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "url", "reflect": false }, "language": { "type": "string", "mutable": false, "complexType": { "original": "'warpscript' | 'flows'", "resolved": "\"flows\" | \"warpscript\"", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "language", "reflect": false, "defaultValue": "'warpscript'" }, "vars": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "getter": false, "setter": false, "attribute": "vars", "reflect": false, "defaultValue": "'{}'" } }; } static get states() { return { "height": {}, "parsing": {}, "rendering": {}, "chartOpts": {}, "expanded": {}, "innerOptions": {} }; } static get events() { return [{ "method": "draw", "name": "draw", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "void", "resolved": "void", "references": {} } }, { "method": "dataZoom", "name": "dataZoom", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "{ start?: number, end?: number, min?: number, max?: number, type?: string }", "resolved": "{ start?: number; end?: number; min?: number; max?: number; type?: string; }", "references": {} } }, { "method": "dataPointOver", "name": "dataPointOver", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }, { "method": "dataPointSelected", "name": "dataPointSelected", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }, { "method": "timeBounds", "name": "timeBounds", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }, { "method": "leftMarginComputed", "name": "leftMarginComputed", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "number", "resolved": "number", "references": {} } }, { "method": "poi", "name": "poi", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }, { "method": "discoveryEvent", "name": "discoveryEvent", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "DiscoveryEvent", "resolved": "DiscoveryEvent", "references": { "DiscoveryEvent": { "location": "import", "path": "../../model/types", "id": "src/model/types.ts::DiscoveryEvent" } } } }, { "method": "execError", "name": "execError", "bubbles": true, "cancelable": true, "composed": true, "docs": { "tags": [], "text": "" }, "complexType": { "original": "any", "resolved": "any", "references": {} } }]; } static get methods() { return { "resize": { "complexType": { "signature": "() => Promise<void>", "parameters": [], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<void>" }, "docs": { "text": "", "tags": [] } }, "show": { "complexType": { "signature": "(regexp: string) => Promise<void>", "parameters": [{ "name": "regexp", "type": "string", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<void>" }, "docs": { "text": "", "tags": [] } }, "hide": { "complexType": { "signature": "(regexp: string) => Promise<void>", "parameters": [{ "name": "regexp", "type": "string", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<void>" }, "docs": { "text": "", "tags": [] } }, "hideById": { "complexType": { "signature": "(id: number | string) => Promise<void>", "parameters": [{ "name": "id", "type": "string | number", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<void>" }, "docs": { "text": "", "tags": [] } }, "showById": { "complexType": { "signature": "(id: number | string) => Promise<void>", "parameters": [{ "name": "id", "type": "string | number", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<void>" }, "docs": { "text": "", "tags": [] } }, "setZoom": { "complexType": { "signature": "(dataZoom: { start?: number; end?: number; type?: string; }) => Promise<void>", "parameters": [{ "name": "dataZoom", "type": "{ start?: number; end?: number; type?: string; }", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<void>" }, "docs": { "text": "", "tags": [] } }, "export": { "complexType": { "signature": "(type?: \"png\" | \"svg\") => Promise<string>", "parameters": [{ "name": "type", "type": "\"svg\" | \"png\"", "docs": "" }], "references": { "Promise": { "location": "global", "id": "global::Promise" } }, "return": "Promise<string>" }, "docs": { "text": "", "tags": [] } }, "setFocus": {