| | |
| | | |
| | | state = { |
| | | view: 'normal', |
| | | ramp: 'false', |
| | | visible: false, |
| | | datatype: '', |
| | | plot: null, |
| | |
| | | } |
| | | }, |
| | | ], |
| | | rampColorColumns: [ |
| | | { |
| | | title: '指标', |
| | | dataIndex: 'label', |
| | | editable: false, |
| | | width: '20%' |
| | | }, |
| | | { |
| | | title: '颜色1', |
| | | dataIndex: 'color', |
| | | inputType: 'color', |
| | | editable: true, |
| | | width: '30%', |
| | | render: (text, record) => { |
| | | return (<div style={{width: '80px', height: '23px', background: text}}></div>) |
| | | } |
| | | }, |
| | | { |
| | | title: '颜色2', |
| | | dataIndex: 'color1', |
| | | inputType: 'color', |
| | | editable: true, |
| | | width: '30%', |
| | | render: (text, record) => { |
| | | return (<div style={{width: '80px', height: '23px', background: text}}></div>) |
| | | } |
| | | }, |
| | | ], |
| | | statColorColumns: [ |
| | | { |
| | | title: '指标', |
| | |
| | | inputType: 'color', |
| | | editable: true, |
| | | width: '40%', |
| | | render: (text, record) => { |
| | | return (<div style={{width: '80px', height: '23px', background: text}}></div>) |
| | | } |
| | | }, |
| | | ], |
| | | rampStatColorColumns: [ |
| | | { |
| | | title: '指标', |
| | | dataIndex: 'type', |
| | | inputType: 'input', |
| | | editable: true, |
| | | width: '20%' |
| | | }, |
| | | { |
| | | title: '颜色1', |
| | | dataIndex: 'color', |
| | | inputType: 'color', |
| | | editable: true, |
| | | width: '30%', |
| | | render: (text, record) => { |
| | | return (<div style={{width: '80px', height: '23px', background: text}}></div>) |
| | | } |
| | | }, |
| | | { |
| | | title: '颜色2', |
| | | dataIndex: 'color1', |
| | | inputType: 'color', |
| | | editable: true, |
| | | width: '30%', |
| | | render: (text, record) => { |
| | | return (<div style={{width: '80px', height: '23px', background: text}}></div>) |
| | | } |
| | |
| | | this.setState({ |
| | | visible: true, |
| | | view: 'normal', |
| | | ramp: config.plot.ramp || 'false', |
| | | datatype: config.plot.datatype || 'query', |
| | | fieldName: fieldName, |
| | | plot: fromJS(config.plot).toJS(), |
| | |
| | | this.setState({plot: {...plot, mutilBar: val}}) |
| | | } |
| | | |
| | | rampChange = (e) => { |
| | | const { plot } = this.state |
| | | let val = e.target.value |
| | | let colors = plot.colors || [] |
| | | |
| | | if (val === 'true') { |
| | | colors = colors.map(item => { |
| | | item.color1 = item.color1 || item.color |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | this.setState({plot: {...plot, colors, ramp: val}, ramp: val}) |
| | | } |
| | | |
| | | onSubmit = () => { |
| | | const { config } = this.props |
| | | const { plot, view } = this.state |
| | |
| | | uuid: Utils.getuuid(), |
| | | type: item, |
| | | label: labels[item] || item, |
| | | color: chartColors[i % limit] |
| | | color: chartColors[i % limit], |
| | | color1: chartColors[i % limit] |
| | | } |
| | | }) |
| | | } |
| | |
| | | plot.colors.push({ |
| | | uuid: Utils.getuuid(), |
| | | type: `指标${plot.colors.length}`, |
| | | color: 'rgb(91, 143, 249)' |
| | | color: 'rgb(91, 143, 249)', |
| | | color1: 'rgb(91, 143, 249)' |
| | | }) |
| | | |
| | | this.setState({plot}) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { view, visible, datatype, plot, colorColumns, statColorColumns, cusColumns, baseFormlist } = this.state |
| | | const { view, visible, datatype, plot, ramp, colorColumns, rampColorColumns, statColorColumns, rampStatColorColumns, cusColumns, baseFormlist } = this.state |
| | | const formItemLayout = { |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | |
| | | </TabPane> |
| | | {plot ? <TabPane tab="颜色设置" key="color"> |
| | | <div> |
| | | <Col span={12} style={{height: '40px', top: '-5px', zIndex: 1}}> |
| | | <Form {...formItemLayout}> |
| | | <Form.Item label="渐变色" style={{marginBottom: 10}}> |
| | | <Radio.Group value={plot.ramp || 'false'} onChange={this.rampChange}> |
| | | <Radio value="false">不使用</Radio> |
| | | <Radio value="true">使用</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Form> |
| | | </Col> |
| | | {datatype === 'statistics' ? <Button className="color-add mk-green" onClick={this.addColor}>{this.props.dict['model.add']}</Button> : null} |
| | | {datatype === 'statistics' ? <EditTable actions={['edit', 'move', 'del']} data={plot.colors || []} columns={statColorColumns} onChange={this.changeColor}/> : null} |
| | | {datatype !== 'statistics' ? <EditTable actions={['edit']} data={plot.colors || []} columns={colorColumns} onChange={this.changeColor}/> : null} |
| | | {datatype === 'statistics' ? <EditTable actions={['edit', 'move', 'del']} data={plot.colors || []} columns={ramp ==='true' ? rampStatColorColumns : statColorColumns} onChange={this.changeColor}/> : null} |
| | | {datatype !== 'statistics' ? <EditTable actions={['edit']} data={plot.colors || []} columns={ramp ==='true' ? rampColorColumns : colorColumns} onChange={this.changeColor}/> : null} |
| | | </div> |
| | | </TabPane> : null} |
| | | {plot ? <TabPane tab="自定义设置" disabled={datatype === 'statistics'} key="custom"> |
| | |
| | | let colorIndex = 0 |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | if (plot.ramp === 'true') { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], `l(0) 0:${item.color} 1:${item.color1}` ) |
| | | } |
| | | }) |
| | | } else { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], item.color) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | let _chart = chart |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color('key', (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | let limit = chartColors.length |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(item.type)) { |
| | | colors.set(item.type, item.color) |
| | | if (plot.ramp === 'true') { |
| | | let bars = {} |
| | | plot.customs.forEach(item => { |
| | | if (!item.shape || !item.shape[0] || item.shape[0] === 'bar') { |
| | | bars[item.type] = true |
| | | } |
| | | }) |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | if (bars[item.type]) { |
| | | colors.set(transfield[item.type], `l(90) 0:${item.color} 1:${item.color1}` ) |
| | | } else { |
| | | colors.set(transfield[item.type], `l(0) 0:${item.color} 1:${item.color1}` ) |
| | | } |
| | | } |
| | | }) |
| | | } else { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], item.color) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | let axisIndex = 0 |
| | |
| | | item.chartType = item.shape ? (item.shape[0] || 'bar') : 'bar' |
| | | item.shape = item.shape ? (item.shape[1] || '') : '' |
| | | |
| | | if (colors.get(item.type)) { |
| | | item.color = colors.get(item.type) |
| | | if (colors.has(item.name)) { |
| | | item.color = colors.get(item.name) |
| | | } else { |
| | | item.color = chartColors[colorIndex % limit] |
| | | colorIndex++ |
| | |
| | | |
| | | view1.legend(false) |
| | | |
| | | let colors = new Map() |
| | | let colorIndex = 0 |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], item.color) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | if (plot.mutilBar !== 'stack') { |
| | | let _chart = view1 |
| | | .interval() |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color('key', (key) => { |
| | | if (colors.get(key)) { |
| | | // return 'l(90) 0:#1890ff 1:#70cdd0' |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color('key', (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | let colorIndex = 0 |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | if (plot.ramp === 'true') { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], `l(90) 0:${item.color} 1:${item.color1}` ) |
| | | } |
| | | }) |
| | | } else { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(transfield[item.type])) { |
| | | colors.set(transfield[item.type], item.color) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | |
| | | if (plot.adjust !== 'stack') { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color('key', (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color('key', (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | import Editor from '@/assets/mobimg/editor.png' |
| | | import SandBox from '@/assets/mobimg/sandbox.png' |
| | | import Pie1 from '@/assets/mobimg/ring.png' |
| | | import Pie3 from '@/assets/mobimg/nest.png' |
| | | import Pie2 from '@/assets/mobimg/nightingale.png' |
| | | import Mainsearch from '@/assets/mobimg/mainsearch.png' |
| | | import Carousel from '@/assets/mobimg/carousel.png' |
| | |
| | | { type: 'menu', url: bar1, component: 'bar', subtype: 'bar1', title: '条形图', width: 24 }, |
| | | { type: 'menu', url: Pie, component: 'pie', subtype: 'pie', title: '饼图', width: 12 }, |
| | | { type: 'menu', url: Pie1, component: 'pie', subtype: 'ring', title: '环图', width: 12 }, |
| | | { type: 'menu', url: Pie3, component: 'pie', subtype: 'nest', title: '嵌套饼图', width: 12 }, |
| | | { type: 'menu', url: Pie2, component: 'pie', subtype: 'nightingale', title: '南丁格尔图', width: 12 }, |
| | | { type: 'menu', url: dashboard, component: 'dashboard', subtype: 'dashboard', title: '仪表盘', width: 12 }, |
| | | { type: 'menu', url: scatter, component: 'scatter', subtype: 'scatter', title: '散点图', width: 24 }, |
| | |
| | | import Editor from '@/assets/mobimg/editor.png' |
| | | import SandBox from '@/assets/mobimg/sandbox.png' |
| | | import Pie1 from '@/assets/mobimg/ring.png' |
| | | import Pie3 from '@/assets/mobimg/nest.png' |
| | | import Pie2 from '@/assets/mobimg/nightingale.png' |
| | | import Mainsearch from '@/assets/mobimg/mainsearch.png' |
| | | import Navbar from '@/assets/mobimg/navbar.png' |
| | |
| | | { type: 'menu', url: bar1, component: 'bar', subtype: 'bar1', title: '条形图', width: 24 }, |
| | | { type: 'menu', url: Pie, component: 'pie', subtype: 'pie', title: '饼图', width: 12 }, |
| | | { type: 'menu', url: Pie1, component: 'pie', subtype: 'ring', title: '环图', width: 12 }, |
| | | { type: 'menu', url: Pie3, component: 'pie', subtype: 'nest', title: '嵌套饼图', width: 12 }, |
| | | { type: 'menu', url: Pie2, component: 'pie', subtype: 'nightingale', title: '南丁格尔图', width: 12 }, |
| | | { type: 'menu', url: dashboard, component: 'dashboard', subtype: 'dashboard', title: '仪表盘', width: 12 }, |
| | | { type: 'menu', url: scatter, component: 'scatter', subtype: 'scatter', title: '散点图', width: 24 }, |
| | |
| | | item.chartType = item.shape ? (item.shape[0] || 'bar') : 'bar' |
| | | item.shape = item.shape ? (item.shape[1] || '') : '' |
| | | |
| | | if (colors.get(item.type)) { |
| | | if (colors.has(item.type)) { |
| | | item.color = colors.get(item.type) |
| | | } else { |
| | | item.color = chartColors[colorIndex % limit] |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color(_typefield, (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | .point() |
| | | .position(`${plot.Xaxis}*${_valfield}`) |
| | | .color(_typefield, (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | .size(3) |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color('key', (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color('key', (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color(_typefield, (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color(_typefield, (key) => { |
| | | if (colors.get(key)) { |
| | | if (colors.has(key)) { |
| | | return colors.get(key) |
| | | } else { |
| | | colors.set(key, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | let type = plot.type |
| | | let color = plot.color |
| | | |
| | | let colors = new Map() |
| | | let colorIndex = 0 |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | plot.colors.forEach(item => { |
| | | if (!colors.has(item.label)) { |
| | | colors.set(item.label, item.color) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | let _data = this.getnestdata() |
| | | |
| | | const dvx = new DataView().source(_data) |
| | |
| | | .interval() |
| | | .adjust('stack') |
| | | .position(Y_axis) |
| | | .color(type) |
| | | .tooltip(`${type}*${Y_axis}`, (type, percent) => { |
| | | if (plot.show !== 'value') { |
| | | percent = (percent * 100).toFixed(2) + '%' |
| | |
| | | lineWidth: 1, |
| | | stroke: '#fff', |
| | | }) |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | chart1.color(type, (_type) => { |
| | | if (colors.has(_type)) { |
| | | return colors.get(_type) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | | chart1.color(type) |
| | | } |
| | | |
| | | if (plot.label !== 'false') { |
| | | chart1.label(type, { |
| | |
| | | .interval() |
| | | .adjust('stack') |
| | | .position(Y_axis) |
| | | .color(X_axis) |
| | | .tooltip(`${X_axis}*${Y_axis}`, (name, value) => { |
| | | if (plot.show !== 'value') { |
| | | value = (value * 100).toFixed(2) + '%' |
| | |
| | | lineWidth: 1, |
| | | stroke: '#fff', |
| | | }) |
| | | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | chart2.color(X_axis, (type) => { |
| | | if (colors.has(type)) { |
| | | return colors.get(type) |
| | | } else { |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | | chart2.color(X_axis) |
| | | } |
| | | |
| | | if (plot.label !== 'false') { |
| | | if (plot.label === 'inner') { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color(X_axis, (type) => { |
| | | if (colors.get(type)) { |
| | | if (colors.has(type)) { |
| | | return colors.get(type) |
| | | } else { |
| | | colors.set(type, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | if (plot.colors && plot.colors.length > 0) { |
| | | let limit = chartColors.length |
| | | _chart.color(X_axis, (type) => { |
| | | if (colors.get(type)) { |
| | | if (colors.has(type)) { |
| | | return colors.get(type) |
| | | } else { |
| | | colors.set(type, chartColors[colorIndex % limit]) |
| | | colorIndex++ |
| | | return chartColors[(colorIndex - 1) % limit] |
| | | } |
| | | }) |
| | | } else { |
| | |
| | | UNSAFE_componentWillMount () { |
| | | const { data, actions } = this.props |
| | | let columns = fromJS(this.props.columns).toJS() |
| | | let operation = null |
| | | |
| | | if (actions && (actions.includes('edit') || actions.includes('copy') || actions.includes('del'))) { |
| | | let _operation = null |
| | |
| | | return item.dataIndex !== 'operation' |
| | | }) |
| | | |
| | | let operation = { |
| | | operation = { |
| | | title: (<div> |
| | | {eTDict['model.operation']} |
| | | {actions.includes('copy') ? ( |
| | |
| | | |
| | | this.setState({ |
| | | data: data || [], |
| | | oricolumns: fromJS(this.props.columns).toJS(), |
| | | operation, |
| | | columns |
| | | }) |
| | | } |
| | |
| | | UNSAFE_componentWillReceiveProps (nextProps) { |
| | | if (!is(fromJS(this.state.data), fromJS(nextProps.data))) { |
| | | this.setState({data: nextProps.data, editingKey: ''}) |
| | | } else if (!is(fromJS(this.state.oricolumns), fromJS(nextProps.columns))) { |
| | | } else if (!is(fromJS(this.props.columns), fromJS(nextProps.columns))) { |
| | | if (nextProps.columns.length === this.props.columns.length) { |
| | | let cols = {} |
| | | nextProps.columns.forEach(col => {cols[col.dataIndex] = col}) |
| | | |
| | | this.setState({ |
| | | oricolumns: fromJS(nextProps.columns).toJS(), |
| | | columns: this.state.columns.map(col => { |
| | | if (cols[col.dataIndex]) { |
| | | return cols[col.dataIndex] |
| | |
| | | return col |
| | | }) |
| | | }) |
| | | } else { |
| | | let columns = fromJS(nextProps.columns).toJS() |
| | | if (this.state.operation) { |
| | | columns.push(this.state.operation) |
| | | } |
| | | this.setState({columns}) |
| | | } |
| | | } |
| | | } |
| | | |