| | |
| | | let xfields = columns.filter(item => /^Nvarchar/ig.test(item.datatype)) |
| | | let yfields = columns.filter(item => /^(Int|Decimal)/ig.test(item.datatype)) |
| | | |
| | | let labelOptions = [{ |
| | | value: 'false', |
| | | text: '隐藏' |
| | | }, { |
| | | value: 'true', |
| | | text: '显示' |
| | | }] |
| | | |
| | | if (card.chartType === 'bar') { |
| | | labelOptions[1].text = '外部' |
| | | labelOptions.push(...[{ |
| | | value: 'top', |
| | | text: '顶部' |
| | | }, { |
| | | value: 'middle', |
| | | text: '中间' |
| | | }, { |
| | | value: 'bottom', |
| | | text: '底部' |
| | | }]) |
| | | } |
| | | |
| | | return [ |
| | | { |
| | | type: 'radio', |
| | |
| | | text: '百分比' |
| | | }] |
| | | }, { |
| | | type: 'radio', |
| | | type: labelOptions.length > 2 ? 'select' : 'radio', |
| | | key: 'label', |
| | | label: '标注值', |
| | | label: '标签', |
| | | initVal: card.label || 'false', |
| | | required: false, |
| | | options: labelOptions |
| | | }, { |
| | | type: 'radio', |
| | | key: 'labelColor', |
| | | label: '标签颜色', |
| | | initVal: card.labelColor || 'system', |
| | | tooltip: '使用系统色时,使用色系选项设置的系统颜色,使用自定义为颜色设置中定义的图形颜色。', |
| | | required: false, |
| | | options: [{ |
| | | value: 'true', |
| | | text: '显示' |
| | | value: 'system', |
| | | text: '系统' |
| | | }, { |
| | | value: 'false', |
| | | text: '隐藏' |
| | | value: 'custom', |
| | | text: '自定义' |
| | | }] |
| | | // }, { |
| | | // type: 'radio', |
| | |
| | | } else { |
| | | _chart.color('key') |
| | | } |
| | | if (plot.label === 'true') { |
| | | _chart.label('value', (value) => { |
| | | if (plot.label !== 'false') { |
| | | _chart.label('value*key', (value, key) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | let _color = color |
| | | |
| | | if (plot.labelColor === 'custom' && colors.has(key)) { |
| | | _color = colors.get(key) |
| | | } |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: color |
| | | fill: _color |
| | | } |
| | | } |
| | | }) |
| | |
| | | chart.scale({ |
| | | nice: true |
| | | }) |
| | | |
| | | let lablecfg = { |
| | | position: 'top', |
| | | offset: 2, |
| | | style: { |
| | | fill: '#fff' |
| | | } |
| | | } |
| | | |
| | | if (plot.label === 'top') { |
| | | lablecfg.offset = -5 |
| | | lablecfg.style.textBaseline = 'top' |
| | | } else if (plot.label === 'middle') { |
| | | lablecfg.position = 'middle' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'bottom') { |
| | | lablecfg.position = 'bottom' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'true') { |
| | | lablecfg.style.fill = color |
| | | } |
| | | |
| | | if (Bar_axis.length) { |
| | | const view1 = chart.createView({ |
| | |
| | | } else { |
| | | _chart.color('key') |
| | | } |
| | | if (plot.label === 'true') { |
| | | _chart.label('value', (value) => { |
| | | if (plot.label !== 'false') { |
| | | _chart.label('value*key', (value, key) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | |
| | | if (plot.label === 'true' && plot.labelColor === 'custom' && colors.has(key)) { |
| | | lablecfg.style.fill = colors.get(key) |
| | | } |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: color |
| | | } |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | } else { |
| | | _chart.color('key') |
| | | } |
| | | if (plot.label === 'true') { |
| | | _chart.label('value', (value) => { |
| | | if (plot.label !== 'false') { |
| | | _chart.label('value*key', (value, key) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | |
| | | if (plot.label === 'true' && plot.labelColor === 'custom' && colors.has(key)) { |
| | | lablecfg.style.fill = colors.get(key) |
| | | } |
| | | |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: color |
| | | } |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | if (plot.barSize) { |
| | | _chart.size(plot.barSize || 35) |
| | | } |
| | | if (item.label === 'true') { |
| | | if (item.label !== 'false') { |
| | | _chart.label(item.name, (value) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | |
| | | if (plot.label === 'true' && plot.labelColor === 'custom') { |
| | | lablecfg.style.fill = item.color |
| | | } |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: color |
| | | } |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | } |
| | | }) |
| | | |
| | | if (item.label === 'true') { |
| | | if (item.label !== 'false') { |
| | | _chart.label(item.name, (value) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | let _color = color |
| | | |
| | | if (plot.labelColor === 'custom') { |
| | | _color = item.color |
| | | } |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: color |
| | | fill: _color |
| | | } |
| | | } |
| | | }) |
| | |
| | | }) |
| | | } |
| | | |
| | | if (plot.transpose === 'true') { |
| | | chart.coordinate().transpose() |
| | | } |
| | | |
| | | if (plot.coordinate === 'polar') { |
| | | chart.coordinate('polar', { |
| | | innerRadius: 0.1, |
| | |
| | | |
| | | let colors = new Map() |
| | | let colorIndex = 0 |
| | | let lablecfg = { |
| | | position: 'top', |
| | | offset: 2, |
| | | style: { |
| | | fill: '#fff' |
| | | } |
| | | } |
| | | |
| | | if (plot.label === 'top') { |
| | | lablecfg.offset = -5 |
| | | lablecfg.style.textBaseline = 'top' |
| | | } else if (plot.label === 'middle') { |
| | | lablecfg.position = 'middle' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'bottom') { |
| | | lablecfg.position = 'bottom' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'true') { |
| | | lablecfg.style.fill = color |
| | | } |
| | | |
| | | if (plot.transpose === 'true') { |
| | | chart.coordinate().transpose() |
| | | if (plot.label === 'top') { |
| | | delete lablecfg.style.textBaseline |
| | | lablecfg.position = 'right' |
| | | lablecfg.offset = -3 |
| | | lablecfg.style.textAlign = 'end' |
| | | } else if (plot.label === 'middle') { |
| | | lablecfg.position = 'middle' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'bottom') { |
| | | lablecfg.position = 'left' |
| | | lablecfg.offset = 2 |
| | | } else if (plot.label === 'true') { |
| | | lablecfg.position = 'right' |
| | | lablecfg.offset = 2 |
| | | } |
| | | } |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | if (plot.ramp === 'true') { |
| | |
| | | } else { |
| | | _chart.color('key') |
| | | } |
| | | if (plot.label === 'true') { |
| | | _chart.label('value', (value) => { |
| | | if (plot.label !== 'false') { |
| | | _chart.label('value*key', (value, key) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | |
| | | if (plot.label === 'true' && plot.labelColor === 'custom' && colors.has(key)) { |
| | | lablecfg.style.fill = colors.get(key) |
| | | } |
| | | |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: color |
| | | } |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | } else { |
| | | _chart.color('key') |
| | | } |
| | | if (plot.label === 'true') { |
| | | _chart.label('value', (value) => { |
| | | if (plot.label !== 'false') { |
| | | _chart.label('value*key', (value, key) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | |
| | | if (plot.label === 'true' && plot.labelColor === 'custom' && colors.has(key)) { |
| | | lablecfg.style.fill = colors.get(key) |
| | | } |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: color |
| | | } |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.viewrender() |
| | | MKEmitter.addListener('tabsChange', this.handleTabsChange) |
| | | MKEmitter.addListener('submitStyle', this.getStyle) |
| | | |
| | | setTimeout(() => { |
| | | this.viewrender() |
| | | }, 1000) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | { |
| | | type: 'radio', |
| | | key: 'label', |
| | | label: '标注值', |
| | | label: '标签', |
| | | initVal: card.label || 'false', |
| | | required: false, |
| | | options: [{ |
| | |
| | | text: '内侧' |
| | | }, { |
| | | value: 'outer', |
| | | text: '外侧' |
| | | text: '蜘蛛' |
| | | }, { |
| | | value: 'normal', |
| | | text: '常规' |
| | | }], |
| | | }, { |
| | | type: 'radio', |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | this.pierender() |
| | | MKEmitter.addListener('tabsChange', this.handleTabsChange) |
| | | MKEmitter.addListener('submitStyle', this.getStyle) |
| | | |
| | | setTimeout(() => { |
| | | this.viewrender() |
| | | }, 1000) |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | |
| | | } |
| | | |
| | | this.$timer && clearTimeout(this.$timer) |
| | | this.$timer = setTimeout(this.pierender, 100) |
| | | this.$timer = setTimeout(this.viewrender, 100) |
| | | } |
| | | } |
| | | |
| | | viewrender = () => { |
| | | const { card } = this.state |
| | | |
| | | if (card.plot.shape === 'nest') { |
| | | this.nestrender() |
| | | } else { |
| | | this.pierender() |
| | | } |
| | | } |
| | | |
| | |
| | | chart2.label(Y_axis, { |
| | | offset: -30, |
| | | content: (data) => { |
| | | let _label = '' |
| | | let _val = '' |
| | | if (plot.show !== 'value') { |
| | | _val = `${(data[Y_axis] * 100).toFixed(2)}%` |
| | | } else { |
| | | _val = `${data[Y_axis]}` |
| | | } |
| | | if (plot.label === 'inner') { |
| | | _label = _val |
| | | } else { |
| | | _label = `${data[X_axis]}: ${_val}` |
| | | } |
| | | return _label |
| | | return _val |
| | | }, |
| | | style: { |
| | | textAlign: 'center', |
| | |
| | | }) |
| | | } else { |
| | | chart2.label(Y_axis, { |
| | | layout: { type: 'pie-spider' }, |
| | | layout: { type: plot.label === 'outer' ? 'pie-spider' : 'fixed-overlap' }, |
| | | labelHeight: 20, |
| | | content: (data) => { |
| | | let _label = '' |
| | | let _val = '' |
| | | if (plot.show !== 'value') { |
| | | _val = `${(data[Y_axis] * 100).toFixed(2)}%` |
| | | } else { |
| | | _val = `${data[Y_axis]}` |
| | | } |
| | | if (plot.label === 'inner') { |
| | | _label = _val |
| | | } else { |
| | | _label = `${data[X_axis]}: ${_val}` |
| | | } |
| | | return _label |
| | | |
| | | return `${data[X_axis]}: ${_val}` |
| | | }, |
| | | labelLine: { |
| | | style: { |
| | |
| | | pierender = () => { |
| | | const { card } = this.state |
| | | const plot = card.plot |
| | | |
| | | if (plot.shape === 'nest') { |
| | | this.nestrender() |
| | | return |
| | | } |
| | | |
| | | let color = plot.color || 'rgba(0, 0, 0, 0.85)' |
| | | let X_axis = plot.Xaxis || 'x' |
| | |
| | | _chart.label(Y_axis, { |
| | | offset: -30, |
| | | content: (data) => { |
| | | let _label = '' |
| | | let _val = '' |
| | | if (plot.show !== 'value') { |
| | | _val = `${(data[Y_axis] * 100).toFixed(2)}%` |
| | | } else { |
| | | _val = `${data[Y_axis]}` |
| | | } |
| | | if (plot.label === 'inner') { |
| | | _label = _val |
| | | } else { |
| | | _label = `${data[X_axis]}: ${_val}` |
| | | } |
| | | return _label |
| | | return _val |
| | | }, |
| | | style: { |
| | | textAlign: 'center', |
| | |
| | | }) |
| | | } else { |
| | | _chart.label(Y_axis, { |
| | | layout: { type: 'pie-spider' }, |
| | | layout: { type: plot.label === 'outer' ? 'pie-spider' : 'fixed-overlap' }, |
| | | labelHeight: 20, |
| | | content: (data) => { |
| | | let _label = '' |
| | | let _val = '' |
| | | if (plot.show !== 'value') { |
| | | _val = `${(data[Y_axis] * 100).toFixed(2)}%` |
| | | } else { |
| | | _val = `${data[Y_axis]}` |
| | | } |
| | | if (plot.label === 'inner') { |
| | | _label = _val |
| | | } else { |
| | | _label = `${data[X_axis]}: ${_val}` |
| | | } |
| | | return _label |
| | | |
| | | return `${data[X_axis]}: ${_val}` |
| | | }, |
| | | labelLine: { |
| | | style: { |
| | |
| | | } |
| | | this.$timer && clearTimeout(this.$timer) |
| | | this.$timer = setTimeout(() => { |
| | | this.pierender() |
| | | this.viewrender() |
| | | }, 150) |
| | | } |
| | | |
| | |
| | | nice: true |
| | | }) |
| | | |
| | | let lablecfg = { |
| | | position: 'top', |
| | | offset: 2, |
| | | style: { |
| | | fill: '#fff' |
| | | } |
| | | } |
| | | |
| | | if (plot.label === 'top') { |
| | | lablecfg.offset = -5 |
| | | lablecfg.style.textBaseline = 'top' |
| | | } else if (plot.label === 'middle') { |
| | | lablecfg.position = 'middle' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'bottom') { |
| | | lablecfg.position = 'bottom' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'true') { |
| | | lablecfg.style.fill = plot.color |
| | | } |
| | | |
| | | if (plot.Bar_axis) { |
| | | const view1 = chart.createView({ |
| | | region: { |
| | |
| | | _chart.color('key') |
| | | } |
| | | if (plot.label === 'true') { |
| | | _chart.label('value', (value) => { |
| | | _chart.label('value*key', (value, key) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | |
| | | if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { |
| | | lablecfg.style.fill = plot.$colors.get(key) |
| | | } |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: plot.color |
| | | } |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | _chart.color('key') |
| | | } |
| | | if (plot.label === 'true') { |
| | | _chart.label('value', (value) => { |
| | | _chart.label('value*key', (value, key) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { |
| | | lablecfg.style.fill = plot.$colors.get(key) |
| | | } |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: plot.color |
| | | } |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | if (plot.label === 'true' && plot.labelColor === 'custom' && item.color) { |
| | | lablecfg.style.fill = item.color |
| | | } |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: plot.color |
| | | } |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | }) |
| | | } |
| | | |
| | | let offset = {offsetY: 5} |
| | | let lablecfg = { |
| | | position: 'top', |
| | | offset: 2, |
| | | style: { |
| | | fill: '#fff' |
| | | } |
| | | } |
| | | |
| | | if (plot.label === 'top') { |
| | | lablecfg.offset = -5 |
| | | lablecfg.style.textBaseline = 'top' |
| | | } else if (plot.label === 'middle') { |
| | | lablecfg.position = 'middle' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'bottom') { |
| | | lablecfg.position = 'bottom' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'true') { |
| | | lablecfg.style.fill = plot.color |
| | | } |
| | | |
| | | if (plot.transpose === 'true') { |
| | | chart.coordinate().transpose() |
| | | offset = {offsetY: 0, offsetX: -10} |
| | | if (plot.label === 'top') { |
| | | delete lablecfg.style.textBaseline |
| | | lablecfg.position = 'right' |
| | | lablecfg.offset = -3 |
| | | lablecfg.style.textAlign = 'end' |
| | | } else if (plot.label === 'middle') { |
| | | lablecfg.position = 'middle' |
| | | lablecfg.offset = 0 |
| | | } else if (plot.label === 'bottom') { |
| | | lablecfg.position = 'left' |
| | | lablecfg.offset = 2 |
| | | } else if (plot.label === 'true') { |
| | | lablecfg.position = 'right' |
| | | lablecfg.offset = 2 |
| | | } |
| | | } |
| | | |
| | | if (plot.coordinate === 'polar') { |
| | |
| | | _chart.color(_typefield) |
| | | } |
| | | if (plot.label === 'true') { |
| | | _chart.label(_valfield, (value) => { |
| | | _chart.label(`${_valfield}*${_typefield}`, (value, key) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | |
| | | if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { |
| | | lablecfg.style.fill = plot.$colors.get(key) |
| | | } |
| | | |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: plot.color |
| | | }, |
| | | ...offset |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | _chart.color(_typefield) |
| | | } |
| | | if (plot.label === 'true') { |
| | | _chart.label(_valfield, (value) => { |
| | | _chart.label(`${_valfield}*${_typefield}`, (value, key) => { |
| | | if (plot.show === 'percent') { |
| | | value = value + '%' |
| | | } |
| | | |
| | | if (plot.label === 'true' && plot.labelColor === 'custom' && plot.$colors && plot.$colors.has(key)) { |
| | | lablecfg.style.fill = plot.$colors.get(key) |
| | | } |
| | | |
| | | return { |
| | | content: value, |
| | | style: { |
| | | fill: plot.color |
| | | } |
| | | ...lablecfg |
| | | } |
| | | }) |
| | | } |
| | |
| | | } |
| | | |
| | | handleData = () => { |
| | | let _element = document.getElementById(this.state.chartId) |
| | | const { plot, chartId } = this.state |
| | | |
| | | let _element = document.getElementById(chartId) |
| | | if (_element) { |
| | | _element.innerHTML = '' |
| | | } |
| | | this.pierender() |
| | | |
| | | if (plot.shape === 'nest') { |
| | | this.nestrender() |
| | | } else { |
| | | this.pierender() |
| | | } |
| | | } |
| | | |
| | | async loadData (hastimer) { |
| | |
| | | chart2.label(Y_axis, { |
| | | offset: -30, |
| | | content: (data) => { |
| | | let _label = '' |
| | | let _val = '' |
| | | if (plot.show !== 'value') { |
| | | _val = `${(data[Y_axis] * 100).toFixed(2)}%` |
| | | } else { |
| | | _val = `${data[Y_axis]}` |
| | | } |
| | | if (plot.label === 'inner') { |
| | | _label = _val |
| | | } else { |
| | | _label = `${data[X_axis]}: ${_val}` |
| | | } |
| | | return _label |
| | | return _val |
| | | }, |
| | | style: { |
| | | textAlign: 'center', |
| | |
| | | }) |
| | | } else { |
| | | chart2.label(Y_axis, { |
| | | layout: { type: 'pie-spider' }, |
| | | layout: { type: plot.label === 'outer' ? 'pie-spider' : 'fixed-overlap' }, |
| | | labelHeight: 20, |
| | | content: (data) => { |
| | | let _label = '' |
| | | let _val = '' |
| | | if (plot.show !== 'value') { |
| | | _val = `${(data[Y_axis] * 100).toFixed(2)}%` |
| | | } else { |
| | | _val = `${data[Y_axis]}` |
| | | } |
| | | if (plot.label === 'inner') { |
| | | _label = _val |
| | | } else { |
| | | _label = `${data[X_axis]}: ${_val}` |
| | | } |
| | | return _label |
| | | |
| | | return `${data[X_axis]}: ${_val}` |
| | | }, |
| | | labelLine: { |
| | | style: { |
| | |
| | | */ |
| | | pierender = () => { |
| | | const { plot, chartId } = this.state |
| | | |
| | | if (plot.shape === 'nest') { |
| | | this.nestrender() |
| | | return |
| | | } |
| | | |
| | | let color = plot.color |
| | | |
| | |
| | | }) |
| | | } else { |
| | | _chart.label(Y_axis, { |
| | | layout: { type: 'pie-spider' }, |
| | | layout: { type: plot.label === 'outer' ? 'pie-spider' : 'fixed-overlap' }, |
| | | labelHeight: 20, |
| | | content: (data) => { |
| | | let _val = '' |