import Magix from 'magix' import * as View from '../../../../view' Magix.applyStyle('@./crowd-trend.less') export default View.extend({ tmpl: '@crowd-trend.html', init (options) { this.options = options }, render () { const { indicators, isModal, noChannels, inputKey, inputType } = this.options const selectedKey = indicators[0].key const selectedKeyVs = indicators[1].key this.updater.digest({ loading: true, inputType, inputKey, indicators, selectedKey, selectedKeyVs, showTrend: !noChannels, isModal }) this.renderTrend([selectedKey, selectedKeyVs]) }, async renderTrend (keys) { this.updater.digest({ loadingTrend: true }) const { indicators } = this.options const { Accounting } = this.updater.get() const chartOptions = this.getChartOptions(16) const indicatorsMap = Magix.toMap(indicators, 'key') const indicatorsNameMap = Magix.toMap(indicators, 'name') const trendData = await this.getTrendData(keys) const selfInd = indicatorsMap[keys[0]] // 当前指标 const peerInd = indicatorsMap[keys[1]] // 对比指标 const selfName = `${selfInd.name}` const peerName = `${peerInd.name}` for (const trend of trendData) { trend[selfName] = trend[selfInd.key] trend[peerName] = trend[peerInd.key] } // chartOptions.legend.activeEnabled = false chartOptions.graphs[0].field = selfName chartOptions.graphs[1].field = peerName chartOptions.tips = { content: (data, e) => { return `