|
|
@@ -6,8 +6,7 @@ import GRANULARITY from './granularity.json'
|
|
|
const FormItem = Form.Item
|
|
|
const { Option } = Select
|
|
|
|
|
|
-const BarConfigForm = ({ chartDesigner, dispatch, formItemLayout }) => {
|
|
|
-
|
|
|
+const BarConfigForm = ({ autoRefresh, chartDesigner, dispatch, formItemLayout }) => {
|
|
|
const columns = chartDesigner.columns;
|
|
|
|
|
|
return (
|
|
|
@@ -17,8 +16,28 @@ const BarConfigForm = ({ chartDesigner, dispatch, formItemLayout }) => {
|
|
|
className='barconfig-yaxis'
|
|
|
value={[chartDesigner.barConfig.xAxis.column.value, chartDesigner.barConfig.xAxis.granularity.value]}
|
|
|
allowClear={true}
|
|
|
- showSearch
|
|
|
- filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
|
|
|
+ showSearch={{
|
|
|
+ filter: (inputValue, path) => {
|
|
|
+ let p0 = path[0].label.toLowerCase();
|
|
|
+ let v = inputValue.toLowerCase();
|
|
|
+ return p0.indexOf(v) !== -1;
|
|
|
+ },
|
|
|
+ sort: (a, b, inputValue) => {
|
|
|
+ return a[0].label.localeCompare(b[0].label,"zh");
|
|
|
+ },
|
|
|
+ render: (inputValue, path) => {
|
|
|
+ const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
+ let v = inputValue.replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
+ let label0 = (path[0].label.split(new RegExp(`(${v})`, 'i')).map((fragment, i) => {
|
|
|
+ return (
|
|
|
+ fragment.toLowerCase().replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') === v.toLowerCase() ?
|
|
|
+ <span key={i} style={{fontWeight: 'bold', color: 'red'}} className="highlight">{fragment}</span> :
|
|
|
+ fragment
|
|
|
+ )
|
|
|
+ }))
|
|
|
+ return <div>{label0}>{path[1].label}</div>
|
|
|
+ }
|
|
|
+ }}
|
|
|
options={columns.filter(c =>['ordinal', 'categorical', 'time'].indexOf(c.type) !== -1).map((c, i)=>{
|
|
|
|
|
|
return {
|
|
|
@@ -37,7 +56,7 @@ const BarConfigForm = ({ chartDesigner, dispatch, formItemLayout }) => {
|
|
|
if(items.length > 1) {
|
|
|
granularity = { value: items[1].value, label: items[1].label };
|
|
|
}
|
|
|
- dispatch({ type: 'chartDesigner/changeField', name: 'barConfig', value: { ...chartDesigner.barConfig, xAxis: { column, granularity } } });
|
|
|
+ dispatch({ type: 'chartDesigner/changeField', name: 'barConfig', value: { ...chartDesigner.barConfig, xAxis: { column, granularity } }, autoRefresh });
|
|
|
}}
|
|
|
displayRender={(label, selectedOptions) => {
|
|
|
let text = '';
|
|
|
@@ -62,19 +81,39 @@ const BarConfigForm = ({ chartDesigner, dispatch, formItemLayout }) => {
|
|
|
className='gauge-item'
|
|
|
value={[chartDesigner.barConfig.yAxis.column.value, chartDesigner.barConfig.yAxis.gauge.value]}
|
|
|
allowClear={true}
|
|
|
- showSearch
|
|
|
- filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
|
|
|
+ showSearch={{
|
|
|
+ filter: (inputValue, path) => {
|
|
|
+ let p0 = path[0].label.toLowerCase();
|
|
|
+ let v = inputValue.toLowerCase();
|
|
|
+ return p0.indexOf(v) !== -1;
|
|
|
+ },
|
|
|
+ sort: (a, b, inputValue) => {
|
|
|
+ return a[0].label.localeCompare(b[0].label,"zh");
|
|
|
+ },
|
|
|
+ render: (inputValue, path) => {
|
|
|
+ const reg = new RegExp('([+ \\- & | ! ( ) { } \\[ \\] ^ \" ~ * ? : ( ) \/])', 'g'); // 需要转义的字符
|
|
|
+ let v = inputValue.replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1'); // 添加转义符号
|
|
|
+ let label0 = (path[0].label.split(new RegExp(`(${v})`, 'i')).map((fragment, i) => {
|
|
|
+ return (
|
|
|
+ fragment.toLowerCase().replace(new RegExp('(\\\\)', 'g'), '\\$1').replace(reg, '\\$1') === v.toLowerCase() ?
|
|
|
+ <span key={i} style={{fontWeight: 'bold', color: 'red'}} className="highlight">{fragment}</span> :
|
|
|
+ fragment
|
|
|
+ )
|
|
|
+ }))
|
|
|
+ return <div>{label0}>{path[1].label}</div>
|
|
|
+ }
|
|
|
+ }}
|
|
|
options={columns.map((c, i)=>{
|
|
|
return {
|
|
|
value: c.name,
|
|
|
label: c.label,
|
|
|
children: GAUGE[chartDesigner.baseConfig.viewType].map(g => {
|
|
|
- if(g.columnType.indexOf(c.type) !== -1) {
|
|
|
- return g;
|
|
|
- }else {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }).filter( g => g!==null)
|
|
|
+ if(g.columnType.indexOf(c.type) !== -1) {
|
|
|
+ return g;
|
|
|
+ }else {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }).filter( g => g!==null)
|
|
|
}
|
|
|
})}
|
|
|
onChange={(value, items) => {
|
|
|
@@ -84,7 +123,7 @@ const BarConfigForm = ({ chartDesigner, dispatch, formItemLayout }) => {
|
|
|
column = { type: items[0].type, value: items[0].value, label: items[0].label };
|
|
|
gauge = { value: items[1].value, label: items[1].label };
|
|
|
}
|
|
|
- dispatch({ type: 'chartDesigner/changeField', name: 'barConfig', value: { ...chartDesigner.barConfig, yAxis: { column, gauge } } });
|
|
|
+ dispatch({ type: 'chartDesigner/changeField', name: 'barConfig', value: { ...chartDesigner.barConfig, yAxis: { column, gauge } }, autoRefresh });
|
|
|
}}
|
|
|
displayRender={(label, selectedOptions) => {
|
|
|
let menu = selectedOptions.length > 0 ? <Menu
|
|
|
@@ -101,7 +140,7 @@ const BarConfigForm = ({ chartDesigner, dispatch, formItemLayout }) => {
|
|
|
column: chartDesigner.barConfig.yAxis.column,
|
|
|
gauge: { value, label }
|
|
|
}
|
|
|
- }});
|
|
|
+ }, autoRefresh });
|
|
|
e.domEvent.stopPropagation();
|
|
|
}}>{c.label}</Menu.Item>
|
|
|
})}
|
|
|
@@ -130,8 +169,7 @@ const BarConfigForm = ({ chartDesigner, dispatch, formItemLayout }) => {
|
|
|
filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
|
|
|
allowClear={true}
|
|
|
onChange={(value) => {
|
|
|
- // value = value.splice(-1);
|
|
|
- dispatch({ type: 'chartDesigner/changeField', name: 'barConfig', value: { ...chartDesigner.barConfig, groupBy: value } });
|
|
|
+ dispatch({ type: 'chartDesigner/changeField', name: 'barConfig', value: { ...chartDesigner.barConfig, groupBy: value }, autoRefresh });
|
|
|
}}
|
|
|
value={chartDesigner.barConfig.groupBy}
|
|
|
>
|