| | |
| | | data: PropTypes.array, // 图表传入数据 |
| | | loading: PropTypes.bool, // 数据加载中 |
| | | config: PropTypes.object, // 页面配置信息 |
| | | getexceloutparam: PropTypes.func // 获取excel导出参数 |
| | | } |
| | | |
| | | state = { |
| | | dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 字典 |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, // 字典 |
| | | empty: true, // 图表数据为空 |
| | | actions: [], // 图表绑定的按钮组 |
| | | chartId: Utils.getuuid(), // 图表Id |
| | |
| | | percentFields.push(_column.label) |
| | | } |
| | | }) |
| | | } catch { |
| | | } catch (e) { |
| | | console.warn('Incorrect percentage setting') |
| | | } |
| | | } |
| | |
| | | }) |
| | | |
| | | _data = [..._mdata.values()] |
| | | } |
| | | |
| | | if (plot.correction && plot.chartType === 'bar' && _data.length > 0 && _data.length < plot.correction) { |
| | | if (plot.enabled !== 'true' || (plot.customs && plot.customs.filter(cell => cell.chartType !== 'bar').length === 0)) { |
| | | let _num = plot.correction - _data.length |
| | | for (let i = 0; i < _num; i++) { |
| | | let _val = Array( i + 2 ).join(' ') |
| | | let _cell = {} |
| | | _cell[plot.Xaxis] = _val |
| | | _columns.forEach(col => { |
| | | _cell[col.field] = '' |
| | | }) |
| | | |
| | | _data.push(_cell) |
| | | } |
| | | } |
| | | } |
| | | |
| | | this.setState({empty: _data.length === 0}) |
| | |
| | | let _chart = chart |
| | | .interval() |
| | | .position(`${plot.Xaxis}*${_valfield}`) |
| | | .size(30) |
| | | .color(_typefield) |
| | | .adjust([ |
| | | { |
| | |
| | | let _chart = chart |
| | | .interval() |
| | | .position(`${plot.Xaxis}*${_valfield}`) |
| | | .size(30) |
| | | .color(_typefield) |
| | | .adjust('stack') |
| | | .shape(plot.shape || 'rect') |
| | |
| | | } |
| | | }) |
| | | |
| | | if (plot.label === 'true') { |
| | | let setting = { |
| | | if (plot.label !== 'false') { |
| | | _chart.label('percent', { |
| | | layout: { type: 'pie-spider' }, |
| | | labelHeight: 20, |
| | | content: (data) => { |
| | | let val = data[plot.Xaxis] |
| | | if (val) { |
| | |
| | | } |
| | | } |
| | | return `${val}: ${(data.percent * 100).toFixed(2)}%` |
| | | }, |
| | | labelLine: { |
| | | style: { |
| | | lineWidth: 0.5, |
| | | }, |
| | | } |
| | | } |
| | | |
| | | if (plot.labelLayout === 'overlap') { |
| | | setting.type = 'pie' |
| | | setting.layout = { |
| | | type: 'overlap' |
| | | } |
| | | setting.offset = 0 |
| | | } |
| | | |
| | | _chart.label('percent', setting) |
| | | }) |
| | | } |
| | | |
| | | } else { |
| | | let _chart = chart |
| | | .interval() |
| | |
| | | btn={item} |
| | | show="icon" |
| | | setting={config.setting} |
| | | getexceloutparam={this.props.getexceloutparam} |
| | | updateStatus={() => {}} |
| | | /> |
| | | ) |
| | | } else { |
| | |
| | | btn={item} |
| | | show="icon" |
| | | setting={config.setting} |
| | | updateStatus={() => {}} |
| | | /> |
| | | ) |
| | | } |