| | |
| | | |
| | | plot.zoomYaxis = plot.zoomYaxis || 'default' |
| | | |
| | | let datatype = plot.datatype || 'query' |
| | | if (plot.enabled === 'true') { |
| | | datatype = 'custom' |
| | | } |
| | | |
| | | this.setState({ |
| | | visible: true, |
| | | view: 'base', |
| | | datatype: plot.datatype || 'query', |
| | | datatype: datatype, |
| | | fieldName: fieldName, |
| | | plot: plot, |
| | | baseFormlist: getBaseForm(plot, config.columns), |
| | |
| | | }) |
| | | } |
| | | |
| | | enabledChange = (e) => { |
| | | const { plot } = this.state |
| | | let val = e.target.value |
| | | optionChange = (val, key) => { |
| | | let _plot = {...this.state.plot, [key]: val} |
| | | |
| | | if (key === 'ramp' && val === 'true') { |
| | | _plot.colors = _plot.colors || [] |
| | | _plot.colors = _plot.colors.map(item => { |
| | | item.color1 = item.color1 || item.color |
| | | return item |
| | | }) |
| | | } |
| | | |
| | | this.setState({plot: {...plot, enabled: val}}) |
| | | } |
| | | |
| | | zoomChange = (e) => { |
| | | const { plot } = this.state |
| | | let val = e.target.value |
| | | |
| | | this.setState({plot: {...plot, zoomYaxis: val}, cusColumns: this.getCusColumns(val)}) |
| | | this.setState({plot: _plot}, () => { |
| | | if (key === 'zoomYaxis') { |
| | | this.setState({cusColumns: this.getCusColumns(val)}) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | getCusColumns = (zoomYaxis) => { |
| | |
| | | children: [ |
| | | { value: 'rect', label: 'rect(矩形)' }, |
| | | { value: 'hollow-rect', label: 'hollow-rect(空心矩形)' }, |
| | | { value: 'line', label: 'line(线条)' }, |
| | | { value: 'tick', label: 'tick(波动)' }, |
| | | // { value: 'funnel', label: 'funnel' }, |
| | | { value: 'pyramid', label: 'pyramid(角锥)' } |
| | | // { value: 'line', label: 'line(线条)' }, |
| | | // { value: 'tick', label: 'tick(波动)' }, |
| | | // { value: 'funnel', label: 'funnel(漏斗图)' }, |
| | | { value: 'pyramid', label: 'pyramid(金字塔)' } |
| | | ], |
| | | } |
| | | ] |
| | |
| | | { value: 'false', text: '隐藏'} |
| | | ], |
| | | render: (text, record) => { |
| | | if (record.axis !== 'true') return '' |
| | | let trans = {'true': '显示', 'false': '隐藏'} |
| | | return trans[text] || '' |
| | | } |
| | |
| | | ], |
| | | render: (text, record) => { |
| | | let trans = {value: '数值', percent: '百分比', thdSeparator: '千分位'} |
| | | return trans[text] || '' |
| | | return trans[text] || '数值' |
| | | } |
| | | }, |
| | | { |
| | |
| | | return cusColumns |
| | | } |
| | | |
| | | mutilBarChange = (e) => { |
| | | const { plot } = this.state |
| | | let val = e.target.value |
| | | |
| | | 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}}) |
| | | } |
| | | |
| | | rampDirectionChange = (e) => { |
| | | const { plot } = this.state |
| | | let val = e.target.value |
| | | |
| | | this.setState({plot: {...plot, rampDirection: val}}) |
| | | } |
| | | |
| | | onSubmit = () => { |
| | | const { config } = this.props |
| | | const { plot, view } = this.state |
| | |
| | | this.normalRef.handleConfirm().then(values => { |
| | | let _plot = {...plot, ...values} |
| | | |
| | | if (_plot.datatype === 'custom') { |
| | | _plot.datatype = 'query' |
| | | _plot.enabled = 'true' |
| | | _plot.show = 'value' |
| | | } else { |
| | | _plot.enabled = 'false' |
| | | } |
| | | |
| | | if (_plot.datatype !== plot.datatype) { |
| | | _plot.colors = null |
| | | } |
| | | |
| | | this.resetPlot(_plot) |
| | | |
| | | this.setState({ |
| | |
| | | if (view === 'normal') { |
| | | this.normalRef.handleConfirm().then(values => { |
| | | let _plot = {...plot, ...values} |
| | | |
| | | if (_plot.datatype === 'custom') { |
| | | _plot.datatype = 'query' |
| | | _plot.enabled = 'true' |
| | | _plot.show = 'value' |
| | | } else { |
| | | _plot.enabled = 'false' |
| | | } |
| | | |
| | | if (_plot.datatype !== plot.datatype) { |
| | | _plot.colors = null |
| | |
| | | resetPlot = (_plot) => { |
| | | const { config } = this.props |
| | | |
| | | if (_plot.chartType === 'bar') { |
| | | _plot.transpose = _plot.shape === 'barChart' ? 'true' : 'false' |
| | | _plot.coordinate = _plot.shape === 'roseChart' ? 'polar' : 'angle' |
| | | if (_plot.shape === 'barChart' || _plot.shape === 'roseChart') { |
| | | _plot.shape = 'rect' |
| | | } |
| | | } |
| | | |
| | | if (_plot.axis) { |
| | | _plot.grid = _plot.axis.includes('grid') ? 'show' : 'hidden' |
| | | _plot.x_line = _plot.axis.includes('x_line') ? 'show' : 'hidden' |
| | | _plot.y_line = _plot.axis.includes('y_line') ? 'show' : 'hidden' |
| | | _plot.tick = _plot.axis.includes('tick') ? 'show' : 'hidden' |
| | | |
| | | delete _plot.axis |
| | | } |
| | | |
| | | if (_plot.tickVals) { |
| | | _plot.x_label = _plot.tickVals.includes('x_label') ? 'show' : 'hidden' |
| | | _plot.y_label = _plot.tickVals.includes('y_label') ? 'show' : 'hidden' |
| | | |
| | | delete _plot.tickVals |
| | | } |
| | | |
| | | if (_plot.datatype === 'statistics') { |
| | | _plot.enabled = 'false' |
| | | _plot.customs = [] |
| | |
| | | name: labels[item] || item, |
| | | axis: i === 0 ? 'true' : 'false', |
| | | label: _plot.label === 'false' ? 'false' : true, |
| | | title: 'true', |
| | | show: 'value', |
| | | title: 'false', |
| | | shape: _plot.chartType === 'bar' && i === 0 ? ['bar', 'rect'] : ['line', 'smooth'] |
| | | } |
| | | }) |
| | |
| | | <Modal |
| | | wrapClassName="mk-pop-modal" |
| | | visible={visible} |
| | | width={1100} |
| | | width={1200} |
| | | maskClosable={false} |
| | | onOk={this.onSubmit} |
| | | onCancel={() => { this.setState({ visible: false }) }} |
| | | destroyOnClose |
| | | > |
| | | {config.name ? <div className="mk-com-name">{config.name} - 编辑</div> : null} |
| | | <Tabs activeKey={view} className="menu-chart-edit-box" onChange={this.changeTab}> |
| | | <Tabs activeKey={view} className="menu-chart-line-edit-box" onChange={this.changeTab}> |
| | | <TabPane tab="组件设置" key="base"> |
| | | <ModalForm formlist={baseFormlist} inputSubmit={this.onSubmit} wrappedComponentRef={(inst) => this.baseRef = inst}/> |
| | | </TabPane> |
| | |
| | | <Col span={8} 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.Group value={plot.ramp || 'false'} onChange={(e) => this.optionChange(e.target.value, 'ramp')}> |
| | | <Radio value="false">不使用</Radio> |
| | | <Radio value="true">使用</Radio> |
| | | </Radio.Group> |
| | |
| | | {plot.chartType === 'line' ? <Col span={8} style={{height: '40px', top: '-5px', zIndex: 1}}> |
| | | <Form {...formItemLayout}> |
| | | <Form.Item label="渐变方向" style={{marginBottom: 10}}> |
| | | <Radio.Group value={plot.rampDirection || 'horizontal'} onChange={this.rampDirectionChange}> |
| | | <Radio.Group value={plot.rampDirection || 'horizontal'} onChange={(e) => this.optionChange(e.target.value, 'rampDirection')}> |
| | | <Radio value="horizontal">水平</Radio> |
| | | <Radio value="vertical">垂直</Radio> |
| | | </Radio.Group> |
| | |
| | | {datatype === 'statistics' ? <Button className="color-add mk-green" onClick={this.addColor}>添加</Button> : null} |
| | | {datatype === 'statistics' ? <EditTable actions={['edit', 'move', 'del']} data={plot.colors || []} columns={plot.ramp ==='true' ? rampStatColorColumns : statColorColumns} onChange={this.changeColor}/> : null} |
| | | {datatype !== 'statistics' ? <EditTable actions={['edit']} data={plot.colors || []} columns={plot.ramp ==='true' ? rampColorColumns : colorColumns} onChange={this.changeColor}/> : null} |
| | | {plot.chartType === 'bar' && plot.datatype === 'query' ? <div className="mk-bar-colors"> |
| | | <p>柱形颜色:可根据柱图序号设置颜色(请设置柱形宽度)。注:使用自定义图形设置或多根柱图时无效。</p> |
| | | {plot.chartType === 'bar' && datatype === 'query' ? <div className="mk-bar-colors"> |
| | | <p>柱形颜色:可根据柱图序号设置颜色。注:多根柱图时无效。</p> |
| | | <div className="bar-color-add"><PlusOutlined onClick={this.addbarColor}/></div> |
| | | <EditTable actions={['edit', 'move', 'del']} data={plot.barcolors || []} columns={barColorColumns} onChange={this.changebarColor}/> |
| | | </div> : null} |
| | | </div> |
| | | </TabPane> : null} |
| | | {plot ? <TabPane tab="自定义图形设置" disabled={datatype === 'statistics'} key="custom"> |
| | | <Col span={8}> |
| | | {plot ? <TabPane tab="自定义图形设置" disabled={datatype !== 'custom'} key="custom"> |
| | | {/* <Col span={8}> |
| | | <Form {...formItemLayout}> |
| | | <Form.Item label="是否启用" style={{marginBottom: 10}}> |
| | | <Radio.Group value={plot.enabled || 'false'} onChange={this.enabledChange}> |
| | | <Radio.Group value={plot.enabled || 'false'} onChange={(e) => this.optionChange(e.target.value, 'enabled')}> |
| | | <Radio value="true">是</Radio> |
| | | <Radio value="false">否</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Form> |
| | | </Col> |
| | | <Col span={8}> |
| | | </Col> */} |
| | | {/* <Col span={8}> |
| | | <Form {...formItemLayout}> |
| | | <Form.Item label="多柱排列" style={{marginBottom: 10}}> |
| | | <Radio.Group value={plot.mutilBar || 'dodge'} onChange={this.mutilBarChange}> |
| | | <Radio.Group value={plot.mutilBar || 'dodge'} onChange={(e) => this.optionChange(e.target.value, 'mutilBar')}> |
| | | <Radio value="dodge">分组</Radio> |
| | | <Radio value="stack">堆叠</Radio> |
| | | <Radio value="overlap">重叠</Radio> |
| | | </Radio.Group> |
| | | </Form.Item> |
| | | </Form> |
| | | </Col> |
| | | </Col> */} |
| | | <Col span={8}> |
| | | <Form {...formItemLayout}> |
| | | <Form.Item label="Y轴区间" style={{marginBottom: 10}}> |
| | | <Radio.Group value={plot.zoomYaxis} onChange={this.zoomChange}> |
| | | <Radio.Group value={plot.zoomYaxis} onChange={(e) => this.optionChange(e.target.value, 'zoomYaxis')}> |
| | | <Radio value="default">默认</Radio> |
| | | <Radio value="custom">自定义</Radio> |
| | | <Radio value="adjust">自适应</Radio> |