import Magix from 'magix' import * as View from '../../../../view' Magix.applyStyle('@./ad-trend.less') export default View.extend({ tmpl: '@ad-trend.html', init (options) { this.options = options }, async render () { const { indicators } = this.options const selectedKey = indicators[0].key this.updater.digest({ loading: true, indicators, selectedKey }) this.renderTrend(selectedKey) }, async renderTrend (key) { 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 trendData = await this.getTrendData(key) const selfName = '本店' const peerName = '同行' const indName = indicatorsMap[key].name // 指标中文名 const valueType = indicatorsMap[key].valueType // 数据类型:0,整数,1:小数,2:小数并且百分比 for (const trend of trendData) { trend[selfName] = trend[key] trend[peerName] = trend.peerValue } delete chartOptions.legend chartOptions.graphs[0].field = selfName chartOptions.graphs[1].field = peerName chartOptions.tips = { content: (data, e) => { return `