Browse Source

报表图表修改icon替换/饼图label formatter样式设置

zhuth 6 years ago
parent
commit
5cadbdc87d

+ 27 - 1
src/components/chartDesigner/sections/style/pie.jsx

@@ -1,8 +1,16 @@
 import React from 'react'
-import { Form, Divider, Checkbox } from 'antd'
+import { Form, Divider, Checkbox, Select } from 'antd'
 import { connect } from 'dva'
 import { deepAssign } from '../../../../utils/baseUtils'
 
+const formatters = [
+    { value: '{b}', label: '名称' },
+    { value: '{b} {c}', label: '名称、数值' },
+    { value: '{b} {d}%', label: '名称、百分比' },
+    { value: '{c} {d}%', label: '数值、百分比' },
+    { value: '{b} {c}\n{d}%', label: '全部信息' },
+]
+
 class PieStyleConfig extends React.Component {
     constructor(props) {
         super(props);
@@ -39,6 +47,24 @@ class PieStyleConfig extends React.Component {
                     }}
                 />
             </Form.Item>
+            {!pieStyle.labelHidden && <Form.Item label='格式' {...formItemLayout}>
+                <Select
+                    defaultValue={pieStyle.labelFormatter || '{b}'}
+                    onChange={value => {
+                        let fields = [{ name: 'styleConfig', value: deepAssign(styleConfig, { pie: { labelFormatter: value } }) }];
+                        if(!!chartOption.baseOption) {
+                            fields.push({ name: 'chartOption', value: deepAssign(chartOption, { baseOption: { series: { 0: {
+                                label: { normal: { formatter: value } }
+                            } } } }) });
+                        }
+                        dispatch({ type: 'chartDesigner/setFields', fields });
+                    }}
+                >
+                    {formatters.map((f) => (
+                        <Select.Option value={f.value} key={f.value}>{f.label}</Select.Option>
+                    ))}
+                </Select>
+            </Form.Item>}
         </Form>
     }
 }

+ 3 - 2
src/components/dashboardDesigner/viewLayoutItem.jsx

@@ -1,6 +1,7 @@
 import React from 'react';
 import { connect } from 'dva';
-import { Input, Icon, message } from 'antd'
+import { Input, Icon, message } from 'antd';
+import CusIcon from '../common/cusIcon/index';
 import ChartView from './chartView';
 
 class ViewLayoutItem extends React.Component {
@@ -79,7 +80,7 @@ class ViewLayoutItem extends React.Component {
                             dispatch({ type: 'dashboardDesigner/fetchChartData', item, mandatory: true, page, pageSize });
                         }}/>}
                         {!isPreview && viewType !== 'richText' && <Icon className={iconCls} type="fullscreen" onClick={() => showPreviewBox(item)}/>}
-                        {editMode && !isPreview && (item.creatorCode === currentUser.code || currentUser.role === 'superAdmin') && viewType !== 'richText' &&  <Icon className={iconCls} type='edit' onClick={() => {
+                        {editMode && !isPreview && (item.creatorCode === currentUser.code || currentUser.role === 'superAdmin') && viewType !== 'richText' &&  <CusIcon className={iconCls} type='bi-edit' onClick={() => {
                             dispatch({ type: 'dashboard/remoteModify',hideMessage:true });
                             dispatch({ type: 'dashboardDesigner/reset' });
                             dispatch({ type: 'main/redirect', path: '/chart/' + chartCode });

+ 2 - 1
src/models/parseChartOption.js

@@ -304,7 +304,7 @@ function pieOption(data, pieConfig, themeConfig, styleConfig, drillDown) {
             drillDown
         };
     }
-    let { labelHidden } = styleConfig;
+    let { labelHidden, labelFormatter } = styleConfig;
     let { xAxis, yAxis } = pieConfig;
     let { tooMany } = data;
     let columnName = xAxis.column.label;
@@ -349,6 +349,7 @@ function pieOption(data, pieConfig, themeConfig, styleConfig, drillDown) {
             label: {
                 normal: {
                     show: labelHidden === undefined ? true : !labelHidden,
+                    formatter: labelFormatter || '{b}'
                 },
                 emphasis: {
                     show: true,

File diff suppressed because it is too large
+ 0 - 0
static/iconfont/iconfont.js


Some files were not shown because too many files changed in this diff