Commit 3a8530bfb65f8a510e86277be9f17fd6b6149892
1 parent
485ac3c3
perf: implement chart component render
Showing
5 changed files
with
71 additions
and
44 deletions
src/main/webapp/images/thingskit/empty.png
0 → 100644
2.41 KB
src/main/webapp/images/thingskit/empty.svg
0 → 100644
1 | +<svg viewBox="0 0 79 86" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><linearGradient id="linearGradient-1-1" x1="38.8503086%" y1="0%" x2="61.1496914%" y2="100%"><stop stop-color="#FCFCFD" offset="0%"></stop><stop stop-color="#EEEFF3" offset="100%"></stop></linearGradient><linearGradient id="linearGradient-2-1" x1="0%" y1="9.5%" x2="100%" y2="90.5%"><stop stop-color="#FCFCFD" offset="0%"></stop><stop stop-color="#E9EBEF" offset="100%"></stop></linearGradient><rect id="path-3-1" x="0" y="0" width="17" height="36"></rect></defs><g id="Illustrations" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="B-type" transform="translate(-1268.000000, -535.000000)"><g id="Group-2" transform="translate(1268.000000, 535.000000)"><path id="Oval-Copy-2" d="M39.5,86 C61.3152476,86 79,83.9106622 79,81.3333333 C79,78.7560045 57.3152476,78 35.5,78 C13.6847524,78 0,78.7560045 0,81.3333333 C0,83.9106622 17.6847524,86 39.5,86 Z" fill="#F7F8FC"></path><polygon id="Rectangle-Copy-14" fill="#E5E7E9" transform="translate(27.500000, 51.500000) scale(1, -1) translate(-27.500000, -51.500000) " points="13 58 53 58 42 45 2 45"></polygon><g id="Group-Copy" transform="translate(34.500000, 31.500000) scale(-1, 1) rotate(-25.000000) translate(-34.500000, -31.500000) translate(7.000000, 10.000000)"><polygon id="Rectangle-Copy-10" fill="#E5E7E9" transform="translate(11.500000, 5.000000) scale(1, -1) translate(-11.500000, -5.000000) " points="2.84078316e-14 3 18 3 23 7 5 7"></polygon><polygon id="Rectangle-Copy-11" fill="#EDEEF2" points="-3.69149156e-15 7 38 7 38 43 -3.69149156e-15 43"></polygon><rect id="Rectangle-Copy-12" fill="url(#linearGradient-1-1)" transform="translate(46.500000, 25.000000) scale(-1, 1) translate(-46.500000, -25.000000) " x="38" y="7" width="17" height="36"></rect><polygon id="Rectangle-Copy-13" fill="#F8F9FB" transform="translate(39.500000, 3.500000) scale(-1, 1) translate(-39.500000, -3.500000) " points="24 7 41 7 55 -3.63806207e-12 38 -3.63806207e-12"></polygon></g><rect id="Rectangle-Copy-15" fill="url(#linearGradient-2-1)" x="13" y="45" width="40" height="36"></rect><g id="Rectangle-Copy-17" transform="translate(53.000000, 45.000000)"><mask id="mask-4-1" fill="white"><use xlink:href="#path-3-1"></use></mask><use id="Mask" fill="#E0E3E9" transform="translate(8.500000, 18.000000) scale(-1, 1) translate(-8.500000, -18.000000) " xlink:href="#path-3-1"></use><polygon id="Rectangle-Copy" fill="#D5D7DE" mask="url(#mask-4-1)" transform="translate(12.000000, 9.000000) scale(-1, 1) translate(-12.000000, -9.000000) " points="7 0 24 0 20 18 -1.70530257e-13 16"></polygon></g><polygon id="Rectangle-Copy-18" fill="#F8F9FB" transform="translate(66.000000, 51.500000) scale(-1, 1) translate(-66.000000, -51.500000) " points="62 45 79 45 70 58 53 58"></polygon></g></g></g></svg> |
@@ -253,7 +253,9 @@ | @@ -253,7 +253,9 @@ | ||
253 | */ | 253 | */ |
254 | Sidebar.prototype.enumPermissionPanel = { | 254 | Sidebar.prototype.enumPermissionPanel = { |
255 | DATA_SOURCE: 'dataSource', | 255 | DATA_SOURCE: 'dataSource', |
256 | - DISPLAY_TYPE: 'displayType', | 256 | + // DISPLAY_TYPE: 'displayType', |
257 | + LINE_CHART_EXPAND: 'lineChartExpandDataSource', | ||
258 | + BAR_CHART_EXPAND: 'barChartExpandDataSource', | ||
257 | INTERACTION: 'interaction', | 259 | INTERACTION: 'interaction', |
258 | DYNAMIC_EFFECT: 'dynamicEffect', | 260 | DYNAMIC_EFFECT: 'dynamicEffect', |
259 | VAR_IMAGE: 'variableImage' | 261 | VAR_IMAGE: 'variableImage' |
@@ -610,7 +612,7 @@ | @@ -610,7 +612,7 @@ | ||
610 | //更多图形,显示出来的的标题跟id,同时包括图片 | 612 | //更多图形,显示出来的的标题跟id,同时包括图片 |
611 | 613 | ||
612 | // TODO thingsKit 设置数据绑定展示面板 | 614 | // TODO thingsKit 设置数据绑定展示面板 |
613 | - const { DISPLAY_TYPE, DYNAMIC_EFFECT, DATA_SOURCE, VAR_IMAGE, INTERACTION } = this.enumPermissionPanel | 615 | + const { LINE_CHART_EXPAND, BAR_CHART_EXPAND, DYNAMIC_EFFECT, DATA_SOURCE, VAR_IMAGE, INTERACTION } = this.enumPermissionPanel |
614 | const { LINE, LINE_CHART, REAL_TIME, TITLE, VARIABLE, DEFAULT, BAR_CHART } = this.enumComponentType | 616 | const { LINE, LINE_CHART, REAL_TIME, TITLE, VARIABLE, DEFAULT, BAR_CHART } = this.enumComponentType |
615 | this.setComponentPermission(LINE, [DYNAMIC_EFFECT]) | 617 | this.setComponentPermission(LINE, [DYNAMIC_EFFECT]) |
616 | this.setComponentPermission(DEFAULT, [DYNAMIC_EFFECT]) | 618 | this.setComponentPermission(DEFAULT, [DYNAMIC_EFFECT]) |
@@ -618,8 +620,8 @@ | @@ -618,8 +620,8 @@ | ||
618 | this.setComponentPermission(TITLE, [INTERACTION, DYNAMIC_EFFECT]) | 620 | this.setComponentPermission(TITLE, [INTERACTION, DYNAMIC_EFFECT]) |
619 | this.setComponentPermission(VAR_IMAGE, [DATA_SOURCE, INTERACTION, VAR_IMAGE]) | 621 | this.setComponentPermission(VAR_IMAGE, [DATA_SOURCE, INTERACTION, VAR_IMAGE]) |
620 | this.setComponentPermission(VARIABLE, [DATA_SOURCE, INTERACTION, DYNAMIC_EFFECT]) | 622 | this.setComponentPermission(VARIABLE, [DATA_SOURCE, INTERACTION, DYNAMIC_EFFECT]) |
621 | - this.setComponentPermission(BAR_CHART, [DATA_SOURCE, DISPLAY_TYPE, DYNAMIC_EFFECT]) | ||
622 | - this.setComponentPermission(LINE_CHART, [DATA_SOURCE, DISPLAY_TYPE, DYNAMIC_EFFECT]) | 623 | + this.setComponentPermission(BAR_CHART, [DATA_SOURCE, BAR_CHART_EXPAND, DYNAMIC_EFFECT]) |
624 | + this.setComponentPermission(LINE_CHART, [DATA_SOURCE, LINE_CHART_EXPAND, DYNAMIC_EFFECT]) | ||
623 | 625 | ||
624 | var thingskitEntries = [ | 626 | var thingskitEntries = [ |
625 | { title: "风机", id: 'fan', image: IMAGE_PATH + '/thingskit/风机.png' }, | 627 | { title: "风机", id: 'fan', image: IMAGE_PATH + '/thingskit/风机.png' }, |
@@ -194,6 +194,7 @@ | @@ -194,6 +194,7 @@ | ||
194 | const chartOptionMapping = this.chartOptionMapping | 194 | const chartOptionMapping = this.chartOptionMapping |
195 | const chartsInstanceMapping = this.chartsInstanceMapping | 195 | const chartsInstanceMapping = this.chartsInstanceMapping |
196 | const chartDom = document.getElementById(id); | 196 | const chartDom = document.getElementById(id); |
197 | + if (!chartDom) return | ||
197 | chartDom.style.width = `${width}px` | 198 | chartDom.style.width = `${width}px` |
198 | chartDom.style.height = `${height}px` | 199 | chartDom.style.height = `${height}px` |
199 | const myChart = echarts.init(chartDom); | 200 | const myChart = echarts.init(chartDom); |
@@ -5092,7 +5092,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5092,7 +5092,9 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5092 | 5092 | ||
5093 | const renderMapping = { | 5093 | const renderMapping = { |
5094 | [permissionKey.DATA_SOURCE]: createDataSourcePanel, | 5094 | [permissionKey.DATA_SOURCE]: createDataSourcePanel, |
5095 | - [permissionKey.DISPLAY_TYPE]: createChartBindPanel, | 5095 | + // [permissionKey.DISPLAY_TYPE]: createChartBindPanel, |
5096 | + [permissionKey.LINE_CHART_EXPAND]: createLineChartPanel, | ||
5097 | + [permissionKey.BAR_CHART_EXPAND]: createBarChartPanel, | ||
5096 | [permissionKey.INTERACTION]: createInteractionPanel, | 5098 | [permissionKey.INTERACTION]: createInteractionPanel, |
5097 | [permissionKey.DYNAMIC_EFFECT]: createDynamicEffectPanel, | 5099 | [permissionKey.DYNAMIC_EFFECT]: createDynamicEffectPanel, |
5098 | [permissionKey.VAR_IMAGE]: createVarImagePanel, | 5100 | [permissionKey.VAR_IMAGE]: createVarImagePanel, |
@@ -5208,14 +5210,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5208,14 +5210,18 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5208 | } | 5210 | } |
5209 | 5211 | ||
5210 | function createLineChartPanel() { | 5212 | function createLineChartPanel() { |
5211 | - | 5213 | + createChartBindPanel(true) |
5212 | } | 5214 | } |
5213 | 5215 | ||
5214 | function createBarChartPanel() { | 5216 | function createBarChartPanel() { |
5215 | - | 5217 | + createChartBindPanel(false) |
5216 | } | 5218 | } |
5217 | 5219 | ||
5218 | - function createChartBindPanel() { | 5220 | + /** |
5221 | + * @description 是否是折线图 | ||
5222 | + * @param {boolean} isLineChart | ||
5223 | + */ | ||
5224 | + function createChartBindPanel(isLineChart) { | ||
5219 | const fragment = document.createDocumentFragment() | 5225 | const fragment = document.createDocumentFragment() |
5220 | const chartBindContainer = document.createElement('div') | 5226 | const chartBindContainer = document.createElement('div') |
5221 | chartBindContainer.setAttribute('class', 'chart-panel__style') | 5227 | chartBindContainer.setAttribute('class', 'chart-panel__style') |
@@ -5485,22 +5491,21 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5485,22 +5491,21 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5485 | }) | 5491 | }) |
5486 | 5492 | ||
5487 | const aggergationOptions = [ | 5493 | const aggergationOptions = [ |
5494 | + { id: 'AVG', name: '平均值' }, | ||
5488 | { id: 'MIN', name: '最小值' }, | 5495 | { id: 'MIN', name: '最小值' }, |
5489 | { id: 'MAX', name: '最大值' }, | 5496 | { id: 'MAX', name: '最大值' }, |
5490 | - { id: 'AVG', name: '平均值' }, | ||
5491 | { id: 'SUM', name: '求和' }, | 5497 | { id: 'SUM', name: '求和' }, |
5492 | { id: 'COUNT', name: '计数' }, | 5498 | { id: 'COUNT', name: '计数' }, |
5493 | { id: 'NONE', name: '空' }, | 5499 | { id: 'NONE', name: '空' }, |
5494 | ] | 5500 | ] |
5495 | 5501 | ||
5496 | - | ||
5497 | - | ||
5498 | function createSwitchBindTypeRadio() { | 5502 | function createSwitchBindTypeRadio() { |
5503 | + const realOption = `<input type="radio" name="${enumConst.DATA_TYPE}" value="${enumConst.REAL}" title="实时">` | ||
5499 | return ` | 5504 | return ` |
5500 | <div class="layui-form-item"> | 5505 | <div class="layui-form-item"> |
5501 | <label class="layui-form-label">数据类型</label> | 5506 | <label class="layui-form-label">数据类型</label> |
5502 | <div class="layui-input-block"> | 5507 | <div class="layui-input-block"> |
5503 | - <input type="radio" name="${enumConst.DATA_TYPE}" value="${enumConst.REAL}" title="实时"> | 5508 | + ${isLineChart ? realOption : ''} |
5504 | <input type="radio" name="${enumConst.DATA_TYPE}" value="${enumConst.HISTORY}" title="历史" checked> | 5509 | <input type="radio" name="${enumConst.DATA_TYPE}" value="${enumConst.HISTORY}" title="历史" checked> |
5505 | </div> | 5510 | </div> |
5506 | </div>` | 5511 | </div>` |
@@ -5573,7 +5578,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | @@ -5573,7 +5578,8 @@ DataFormatPanel.prototype.addDataFont = function (container) { | ||
5573 | function echoData() { | 5578 | function echoData() { |
5574 | const { dataSources = [] } = currentNodeData | 5579 | const { dataSources = [] } = currentNodeData |
5575 | const { additional = {} } = dataSources[0] || {} | 5580 | const { additional = {} } = dataSources[0] || {} |
5576 | - const { [enumBindKey.EFFECT_SCOPE]: effectScope } = additional | 5581 | + const { [enumBindKey.EFFECT_SCOPE]: effectScope = 1000 } = additional |
5582 | + console.log(additional) | ||
5577 | linkageIntervalSelect(effectScope) | 5583 | linkageIntervalSelect(effectScope) |
5578 | form.val(CONTAINER_FILTER, additional) | 5584 | form.val(CONTAINER_FILTER, additional) |
5579 | } | 5585 | } |
@@ -11816,7 +11822,6 @@ class EventCenter { | @@ -11816,7 +11822,6 @@ class EventCenter { | ||
11816 | emit(eventName, ...args) { | 11822 | emit(eventName, ...args) { |
11817 | if (this.eventStack.has(eventName)) | 11823 | if (this.eventStack.has(eventName)) |
11818 | this.eventStack.get(eventName).forEach(fn => fn(...args)) | 11824 | this.eventStack.get(eventName).forEach(fn => fn(...args)) |
11819 | - | ||
11820 | } | 11825 | } |
11821 | 11826 | ||
11822 | /** | 11827 | /** |
@@ -12325,10 +12330,12 @@ class DispatchCenter { | @@ -12325,10 +12330,12 @@ class DispatchCenter { | ||
12325 | * @description 分发事件 | 12330 | * @description 分发事件 |
12326 | */ | 12331 | */ |
12327 | publishEvent(eventName, data, message, event, ws) { | 12332 | publishEvent(eventName, data, message, event, ws) { |
12328 | - data = data ? data : {} | ||
12329 | - Object.keys(data).forEach(() => { | ||
12330 | - this.eventBus.emit(eventName, message, event, ws) | ||
12331 | - }) | 12333 | + // data = data ? data : {} |
12334 | + this.eventBus.emit(eventName, message, event, ws) | ||
12335 | + // console.log(arguments) | ||
12336 | + // Object.keys(data).forEach(() => { | ||
12337 | + // this.eventBus.emit(eventName, message, event, ws) | ||
12338 | + // }) | ||
12332 | } | 12339 | } |
12333 | 12340 | ||
12334 | /** | 12341 | /** |
@@ -12530,7 +12537,7 @@ class HandleDataSource { | @@ -12530,7 +12537,7 @@ class HandleDataSource { | ||
12530 | } | 12537 | } |
12531 | else if (dataType === REAL) { | 12538 | else if (dataType === REAL) { |
12532 | template[STARTTs] = Date.now() - scope | 12539 | template[STARTTs] = Date.now() - scope |
12533 | - template['scope'] = 'LATEST_TELEMETRY' | 12540 | + template['timeWindow'] = interval |
12534 | realList.push(template) | 12541 | realList.push(template) |
12535 | this.subscribeEvent(cmdId, this.updateRealTimeDataSource.bind(this)) | 12542 | this.subscribeEvent(cmdId, this.updateRealTimeDataSource.bind(this)) |
12536 | } | 12543 | } |
@@ -12549,6 +12556,10 @@ class HandleDataSource { | @@ -12549,6 +12556,10 @@ class HandleDataSource { | ||
12549 | this.DispatchInstance.eventBus.on(eventName, callback) | 12556 | this.DispatchInstance.eventBus.on(eventName, callback) |
12550 | } | 12557 | } |
12551 | 12558 | ||
12559 | + /** | ||
12560 | + * @description 更新变量值 | ||
12561 | + * @param {} message | ||
12562 | + */ | ||
12552 | updateCommonDataSource(message) { | 12563 | updateCommonDataSource(message) { |
12553 | const { subscriptionId } = message | 12564 | const { subscriptionId } = message |
12554 | const node = this.getNodeByCmdId(subscriptionId) | 12565 | const node = this.getNodeByCmdId(subscriptionId) |
@@ -12560,27 +12571,12 @@ class HandleDataSource { | @@ -12560,27 +12571,12 @@ class HandleDataSource { | ||
12560 | }, node) | 12571 | }, node) |
12561 | } | 12572 | } |
12562 | 12573 | ||
12563 | - updateChartDataSource(message) { | ||
12564 | - const { data = {}, subscriptionId } = message | ||
12565 | - const node = this.getNodeByCmdId(subscriptionId) | ||
12566 | - if (!node) return | ||
12567 | - const enumConst = Sidebar.prototype.enumCellBasicAttribute | ||
12568 | - const chartInstanceMap = Sidebar.prototype.chartsInstanceMapping | ||
12569 | - const chartInstanceId = node.getAttribute(enumConst.CHART_INSTANCE_ID) | ||
12570 | - const instance = chartInstanceMap.get(chartInstanceId) | ||
12571 | - const { attr = [[]] } = this.getBindData(subscriptionId) | ||
12572 | - const [timespan, value] = data[attr][0] | ||
12573 | - console.log('timespan', timespan) | ||
12574 | - console.log('value', value) | ||
12575 | - console.log(instance) | ||
12576 | - console.log('chart', arguments) | ||
12577 | - } | ||
12578 | - | ||
12579 | /** | 12574 | /** |
12580 | * @description 更新实时数据 | 12575 | * @description 更新实时数据 |
12581 | * @param {} message | 12576 | * @param {} message |
12582 | */ | 12577 | */ |
12583 | updateRealTimeDataSource(message) { | 12578 | updateRealTimeDataSource(message) { |
12579 | + console.log(message) | ||
12584 | const { data = {}, subscriptionId } = message | 12580 | const { data = {}, subscriptionId } = message |
12585 | const node = this.getNodeByCmdId(subscriptionId) | 12581 | const node = this.getNodeByCmdId(subscriptionId) |
12586 | if (!node) return | 12582 | if (!node) return |
@@ -12590,8 +12586,12 @@ class HandleDataSource { | @@ -12590,8 +12586,12 @@ class HandleDataSource { | ||
12590 | const chartInstanceType = node.getAttribute(enumConst.COMPONENT_TYPE) | 12586 | const chartInstanceType = node.getAttribute(enumConst.COMPONENT_TYPE) |
12591 | const instance = chartInstanceMap.get(chartInstanceId) | 12587 | const instance = chartInstanceMap.get(chartInstanceId) |
12592 | const { attr = [[]] } = this.getBindData(subscriptionId) | 12588 | const { attr = [[]] } = this.getBindData(subscriptionId) |
12593 | - const historyDataList = data[attr] | 12589 | + const realDataList = data[attr] || [] |
12594 | 12590 | ||
12591 | + const chartWidth = node.getAttribute('width') | ||
12592 | + const chartHeight = node.getAttribute('height') | ||
12593 | + console.log(chartHeight) | ||
12594 | + console.log(chartWidth) | ||
12595 | // chart insstance 是否已经接受过一次消息推送 | 12595 | // chart insstance 是否已经接受过一次消息推送 |
12596 | const isActive = instance.isActive | 12596 | const isActive = instance.isActive |
12597 | if (!isActive) { | 12597 | if (!isActive) { |
@@ -12599,6 +12599,29 @@ class HandleDataSource { | @@ -12599,6 +12599,29 @@ class HandleDataSource { | ||
12599 | const xAxisData = [] | 12599 | const xAxisData = [] |
12600 | const seriesValue = [] | 12600 | const seriesValue = [] |
12601 | const chartOption = { | 12601 | const chartOption = { |
12602 | + title: { | ||
12603 | + // text: '{a|}', | ||
12604 | + subtext: '暂无数据', | ||
12605 | + x: 'center', | ||
12606 | + y: 'center', | ||
12607 | + itemGap: -20, | ||
12608 | + // textStyle: { | ||
12609 | + // rich: { | ||
12610 | + // a: { | ||
12611 | + // color: '#000', | ||
12612 | + // fontSize: '16', | ||
12613 | + // height: 160, | ||
12614 | + // width: 180, | ||
12615 | + // backgroundColor: { | ||
12616 | + // image: '/thingskit-drawio/images/thingskit/empty.svg' | ||
12617 | + // } | ||
12618 | + // } | ||
12619 | + // } | ||
12620 | + // }, | ||
12621 | + subtextStyle: { | ||
12622 | + fontSize: 16 | ||
12623 | + } | ||
12624 | + }, | ||
12602 | tooltip: { | 12625 | tooltip: { |
12603 | trigger: 'axis', | 12626 | trigger: 'axis', |
12604 | axisPointer: { | 12627 | axisPointer: { |
@@ -12638,7 +12661,7 @@ class HandleDataSource { | @@ -12638,7 +12661,7 @@ class HandleDataSource { | ||
12638 | dataZoom: [ | 12661 | dataZoom: [ |
12639 | { | 12662 | { |
12640 | xAxisIndex: 0, | 12663 | xAxisIndex: 0, |
12641 | - // show: false, | 12664 | + show: realDataList.length ? true : false, |
12642 | type: 'slider', | 12665 | type: 'slider', |
12643 | startValue: 0, | 12666 | startValue: 0, |
12644 | endValue: 4 | 12667 | endValue: 4 |
@@ -12646,12 +12669,12 @@ class HandleDataSource { | @@ -12646,12 +12669,12 @@ class HandleDataSource { | ||
12646 | ] | 12669 | ] |
12647 | } | 12670 | } |
12648 | 12671 | ||
12649 | - for (let i = historyDataList.length - 1; i >= 0; i--) { | ||
12650 | - const [timespan, value] = historyDataList[i] | 12672 | + for (let i = realDataList.length - 1; i >= 0; i--) { |
12673 | + const [timespan, value] = realDataList[i] | ||
12651 | xAxisData.push(new Date(Number(timespan)).toLocaleTimeString()) | 12674 | xAxisData.push(new Date(Number(timespan)).toLocaleTimeString()) |
12652 | seriesValue.push(Number(value)) | 12675 | seriesValue.push(Number(value)) |
12653 | } | 12676 | } |
12654 | - | 12677 | + console.log(chartOption) |
12655 | instance.setOption(chartOption) | 12678 | instance.setOption(chartOption) |
12656 | 12679 | ||
12657 | } else { | 12680 | } else { |
@@ -12661,8 +12684,8 @@ class HandleDataSource { | @@ -12661,8 +12684,8 @@ class HandleDataSource { | ||
12661 | const oldEndValue = Number(oldOptions.dataZoom[0].endValue) || 0 | 12684 | const oldEndValue = Number(oldOptions.dataZoom[0].endValue) || 0 |
12662 | const oldStartValue = Number(oldOptions.dataZoom[0].startValue) || 0 | 12685 | const oldStartValue = Number(oldOptions.dataZoom[0].startValue) || 0 |
12663 | 12686 | ||
12664 | - for (let i = historyDataList.length - 1; i >= 0; i--) { | ||
12665 | - const [timespan, value] = historyDataList[i] | 12687 | + for (let i = realDataList.length - 1; i >= 0; i--) { |
12688 | + const [timespan, value] = realDataList[i] | ||
12666 | xAxisData.push(new Date(Number(timespan)).toLocaleTimeString()) | 12689 | xAxisData.push(new Date(Number(timespan)).toLocaleTimeString()) |
12667 | seriesValue.push(Number(value)) | 12690 | seriesValue.push(Number(value)) |
12668 | } | 12691 | } |
@@ -12716,7 +12739,7 @@ class HandleDataSource { | @@ -12716,7 +12739,7 @@ class HandleDataSource { | ||
12716 | const chartInstanceType = node.getAttribute(enumConst.COMPONENT_TYPE) | 12739 | const chartInstanceType = node.getAttribute(enumConst.COMPONENT_TYPE) |
12717 | const instance = chartInstanceMap.get(chartInstanceId) | 12740 | const instance = chartInstanceMap.get(chartInstanceId) |
12718 | const { attr = [[]] } = this.getBindData(subscriptionId) | 12741 | const { attr = [[]] } = this.getBindData(subscriptionId) |
12719 | - const historyDataList = data[attr] | 12742 | + const historyDataList = data[attr] || [] |
12720 | 12743 | ||
12721 | const xAxisData = [] | 12744 | const xAxisData = [] |
12722 | const seriesValue = [] | 12745 | const seriesValue = [] |
@@ -13174,7 +13197,7 @@ class HandleDynamicEffect { | @@ -13174,7 +13197,7 @@ class HandleDynamicEffect { | ||
13174 | 13197 | ||
13175 | this.subscribeEvent(cmdId, this.dispatch(type)) | 13198 | this.subscribeEvent(cmdId, this.dispatch(type)) |
13176 | }) | 13199 | }) |
13177 | - this.sendMsg({ tsSubCmds }) | 13200 | + if (tsSubCmds.length) this.sendMsg({ tsSubCmds }) |
13178 | } | 13201 | } |
13179 | 13202 | ||
13180 | /** | 13203 | /** |