Эх сурвалжийг харах

查看列bug/折线图添加排序

zhuth 6 жил өмнө
parent
commit
a6b2352508

+ 0 - 1
src/components/chartDesigner/sections/toolbar.jsx

@@ -126,7 +126,6 @@ class Toolbar extends React.Component {
                 </div>
                 <div className='tools'>
                     <Button className='tools-button' size='small' onClick={() => {
-                        // dispatch({ type: 'chartDesigner/remoteChartDataList' });
                         this.setState({
                             visibleDataPreviewBox: true
                         })

+ 50 - 50
src/models/chartDesigner.js

@@ -572,15 +572,10 @@ export default {
                 if(viewType === 'aggregateTable') {
                     const { groupBy, targetColumn } = aggregateTableConfig;
                     groupBy.map(g => ({
-                        title: g.label,
-                        dataIndex: g.key,
-                        // render: g.columnType === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
-                    })).concat({
-                        title: targetColumn.label,
-                        dataIndex: targetColumn.name,
-                        render: targetColumn.type === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
-                    }).filter(x => !!x.dataIndex).forEach(x => {
-                        if(!columns.find(c => c.dataIndex === x.dataIndex)) {
+                        label: g.label,
+                        name: g.key,
+                    })).concat([targetColumn]).filter(x => !!x.name).forEach(x => {
+                        if(!columns.find(c => c.name === x.name)) {
                             columns.push(x);
                         }
                     });;
@@ -588,19 +583,19 @@ export default {
                 }else if(viewType === 'line') {
                     const { groupBy, xAxis, yAxis } = lineConfig;
                     [{
-                        title: groupBy ? groupBy.label : '',
-                        dataIndex: groupBy ?groupBy.key : '',
-                        // render: g.columnType === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
+                        label: groupBy ? groupBy.label : '',
+                        name: groupBy ? groupBy.key : '',
+                        type: groupBy ? groupBy.type : '',
                     }, {
-                        title: xAxis.column.label,
-                        dataIndex: xAxis.column.value,
-                        render: xAxis.column.type === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
+                        label: xAxis.column.label,
+                        name: xAxis.column.value,
+                        type: xAxis.column.type,
                     }, {
-                        title: yAxis.column.label,
-                        dataIndex: yAxis.column.value,
-                        render: yAxis.column.type === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
-                    }].filter(x => !!x.dataIndex).forEach(x => {
-                        if(!columns.find(c => c.dataIndex === x.dataIndex)) {
+                        label: yAxis.column.label,
+                        name: yAxis.column.value,
+                        type: yAxis.column.type,
+                    }].filter(x => !!x.name).forEach(x => {
+                        if(!columns.find(c => c.name === x.name)) {
                             columns.push(x);
                         }
                     });;
@@ -608,19 +603,19 @@ export default {
                 }else if(viewType === 'bar') {
                     const { groupBy, xAxis, yAxis } = barConfig;
                     [{
-                        title: groupBy ? groupBy.label : '',
-                        dataIndex: groupBy ? groupBy.key : '',
-                        // render: g.columnType === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
+                        label: groupBy ? groupBy.label : '',
+                        name: groupBy ? groupBy.key : '',
+                        type: groupBy ? groupBy.type : '',
                     }, {
-                        title: xAxis.column.label,
-                        dataIndex: xAxis.column.value,
-                        render: xAxis.column.type === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
+                        label: xAxis.column.label,
+                        name: xAxis.column.value,
+                        type: xAxis.column.type,
                     }, {
-                        title: yAxis.column.label,
-                        dataIndex: yAxis.column.value,
-                        render: yAxis.column.type === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
-                    }].filter(x => !!x.dataIndex).forEach(x => {
-                        if(!columns.find(c => c.dataIndex === x.dataIndex)) {
+                        label: yAxis.column.label,
+                        name: yAxis.column.value,
+                        type: yAxis.column.type,
+                    }].filter(x => !!x.name).forEach(x => {
+                        if(!columns.find(c => c.name === x.name)) {
                             columns.push(x);
                         }
                     });;
@@ -628,15 +623,15 @@ export default {
                 }else if(viewType === 'pie') {
                     const { xAxis, yAxis } = pieConfig;
                     [{
-                        title: xAxis.column.label,
-                        dataIndex: xAxis.column.value,
-                        render: xAxis.column.type === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
+                        label: xAxis.column.label,
+                        name: xAxis.column.value,
+                        type: xAxis.column.type,
                     }, {
-                        title: yAxis.column.label,
-                        dataIndex: yAxis.column.value,
-                        render: yAxis.column.type === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
-                    }].filter(x => !!x.dataIndex).forEach(x => {
-                        if(!columns.find(c => c.dataIndex === x.dataIndex)) {
+                        label: yAxis.column.label,
+                        name: yAxis.column.value,
+                        type: yAxis.column.type,
+                    }].filter(x => !!x.name).forEach(x => {
+                        if(!columns.find(c => c.name === x.name)) {
                             columns.push(x);
                         }
                     });;
@@ -644,19 +639,19 @@ export default {
                 }else if(viewType === 'scatter') {
                     const { groupBy, xAxis, yAxis } = scatterConfig;
                     [{
-                        title: groupBy ? groupBy.label : '',
-                        dataIndex: groupBy ? groupBy.key : '',
-                        // render: g.columnType === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
+                        label: groupBy ? groupBy.label : '',
+                        name: groupBy ? groupBy.key : '',
+                        type: groupBy ? groupBy.type : '',
                     }, {
-                        title: xAxis.column.label,
-                        dataIndex: xAxis.column.value,
-                        render: xAxis.column.type === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
+                        label: xAxis.column.label,
+                        name: xAxis.column.value,
+                        type: xAxis.column.type,
                     }, {
-                        title: yAxis.column.label,
-                        dataIndex: yAxis.column.value,
-                        render: yAxis.column.type === 'time' ? ((v, r, i) => moment(v).format('YYYY-MM-DD')) : v => v
-                    }].filter(x => !!x.dataIndex).forEach(x => {
-                        if(!columns.find(c => c.dataIndex === x.dataIndex)) {
+                        label: yAxis.column.label,
+                        name: yAxis.column.value,
+                        type: yAxis.column.type,
+                    }].filter(x => !!x.name).forEach(x => {
+                        if(!columns.find(c => c.name === x.name)) {
                             columns.push(x);
                         }
                     });;
@@ -665,6 +660,11 @@ export default {
                     columns = dataViewConfig.viewColumns;
                     sortColumn = dataViewConfig.sortColumn.key;
                 }
+
+                if(columns.length === 0) {
+                    // message.error('');
+                    return false;
+                }
                 columnListName = columns.map(c => c.name);
 
                 const body = {

+ 1 - 1
src/models/parseChartOption.js

@@ -179,7 +179,7 @@ function lineOption(data, lineConfig) {
                 type: 'line',
                 data: s.mdata.map(m => {
                     return [m.date, m.value]
-                })
+                }).sort((a, b) => {return new Date(a[0]).getTime() - new Date(b[0]).getTime()} )
             }
         })
     };