namespace hangyejiegou { const chartCatch: antvChart = { toufangfenxiChart: undefined } module.exports = { upLine1() { if (chartCatch.toufangfenxiChart === undefined) return chartCatch.toufangfenxiChart.clear() let key = this.data.select[this.data.select_act].proportionType; let total = 0; this.data.DayList1.map((v: any) => { total += Number(v[key] || 0) * 1000 }) total /= 1000; const data = this.data.DayList1.map((v: any) => { v.p = Number((Number(v[key] / (total || 1)) * 100).toFixed(2)); return v }); if (chartCatch.toufangfenxiChart === undefined) return; chartCatch.toufangfenxiChart.source(data); chartCatch.toufangfenxiChart.legend({ position: 'bottom', nameStyle: { fill: '#404040', // 文本的颜色 fontSize: 12, // 文本大小 textBaseline: 'middle', // 文本基准线,可取 top middle bottom,默认为middle height: 12, // 设置文本的高度 }, itemFormatter: function itemFormatter(val: string) { let p :any= {}; for (let i = 0; i < data.length; i++) { const v = data[i]; if (v.name === val) { p = v break } } return val + ' ' + p.p + "% "; } }); chartCatch.toufangfenxiChart.tooltip(false); chartCatch.toufangfenxiChart.coord('polar', { transposed: true, radius: 1 }); chartCatch.toufangfenxiChart.axis(false); chartCatch.toufangfenxiChart.interval() .position('type*p') .color('name', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0']).adjust('stack'); chartCatch.toufangfenxiChart.render(); }, line1(F2: any, config: any) { if (chartCatch.toufangfenxiChart !== undefined) chartCatch.toufangfenxiChart.destroy(), chartCatch.toufangfenxiChart = undefined; let sys = wx.getSystemInfoSync(); config.height = sys.windowHeight *0.7; chartCatch.toufangfenxiChart = new F2.Chart(config); let key = this.data.select[this.data.select_act].proportionType; let total = 0; this.data.DayList1.map((v: any) => { total += Number(v[key] || 0) * 1000 }) total /= 1000; const data = this.data.DayList1.map((v: any) => { v.p = Number((Number(v[key] / (total || 1)) * 100).toFixed(2)); return v }); if (chartCatch.toufangfenxiChart === undefined) return; chartCatch.toufangfenxiChart.source(data); chartCatch.toufangfenxiChart.legend({ position: 'bottom', nameStyle: { fill: '#404040', // 文本的颜色 fontSize: 12, // 文本大小 textBaseline: 'middle', // 文本基准线,可取 top middle bottom,默认为middle height: 12, // 设置文本的高度 }, itemFormatter: function itemFormatter(val: string) { let p :any= {}; for (let i = 0; i < data.length; i++) { const v = data[i]; if (v.name === val) { p = v break } } return val + ' ' + p.p + "% "; } }); chartCatch.toufangfenxiChart.tooltip(false); chartCatch.toufangfenxiChart.coord('polar', { transposed: true, radius: 1 }); chartCatch.toufangfenxiChart.axis(false); chartCatch.toufangfenxiChart.interval() .position('type*' + key) .color('name', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0']).adjust('stack'); chartCatch.toufangfenxiChart.render(); return chartCatch.toufangfenxiChart; }, clearchart1(){ if (chartCatch.toufangfenxiChart !== undefined) chartCatch.toufangfenxiChart.destroy(), chartCatch.toufangfenxiChart = undefined; } }; }