From b656f58958a5ca54e710b980b98f4b542ff6369f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 10 六月 2021 18:58:21 +0800
Subject: [PATCH] 2021-06-10

---
 src/menu/components/chart/antv-bar/chartcompile/index.jsx    |   19 +++++++++
 src/menu/components/chart/antv-bar/index.jsx                 |    9 ++++
 src/tabviews/custom/components/chart/antv-bar-line/index.jsx |   78 +++++++++++++++++++++-----------------
 src/menu/components/share/normalheader/index.jsx             |   10 +++++
 4 files changed, 79 insertions(+), 37 deletions(-)

diff --git a/src/menu/components/chart/antv-bar/chartcompile/index.jsx b/src/menu/components/chart/antv-bar/chartcompile/index.jsx
index b46092e..0123d18 100644
--- a/src/menu/components/chart/antv-bar/chartcompile/index.jsx
+++ b/src/menu/components/chart/antv-bar/chartcompile/index.jsx
@@ -412,6 +412,13 @@
     this.setState({plot: {...plot, colors, ramp: val}, 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
@@ -597,7 +604,7 @@
             </TabPane>
             {plot ? <TabPane tab="棰滆壊璁剧疆" key="color">
               <div>
-                <Col span={12} style={{height: '40px', top: '-5px', zIndex: 1}}>
+                <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}>
@@ -607,6 +614,16 @@
                     </Form.Item>
                   </Form>
                 </Col>
+                {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 value="horizontal">姘村钩</Radio>
+                        <Radio value="vertical">鍨傜洿</Radio>
+                      </Radio.Group>
+                    </Form.Item>
+                  </Form>
+                </Col> : null}
                 {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={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}
diff --git a/src/menu/components/chart/antv-bar/index.jsx b/src/menu/components/chart/antv-bar/index.jsx
index 60156f0..f6d5eaa 100644
--- a/src/menu/components/chart/antv-bar/index.jsx
+++ b/src/menu/components/chart/antv-bar/index.jsx
@@ -292,9 +292,13 @@
 
       if (plot.colors && plot.colors.length > 0) {
         if (plot.ramp === 'true') {
+          let _s = 'l(0) '
+          if (plot.rampDirection === 'vertical') {
+            _s = 'l(90) '
+          }
           plot.colors.forEach(item => {
             if (!colors.has(transfield[item.type])) {
-              colors.set(transfield[item.type], `l(0) 0:${item.color} 1:${item.color1}` )
+              colors.set(transfield[item.type], `${_s}0:${item.color} 1:${item.color1}` )
             }
           })
         } else {
@@ -324,6 +328,9 @@
         let limit = chartColors.length
         _chart.color('key', (key) => {
           if (colors.has(key)) {
+            if (plot.area === 'true' && plot.rampDirection === 'vertical') {
+              return colors.get(key).replace(/l\(9?0\) 0:|\s1:.*/ig, '')
+            }
             return colors.get(key)
           } else {
             colorIndex++
diff --git a/src/menu/components/share/normalheader/index.jsx b/src/menu/components/share/normalheader/index.jsx
index f2274ba..732d111 100644
--- a/src/menu/components/share/normalheader/index.jsx
+++ b/src/menu/components/share/normalheader/index.jsx
@@ -18,6 +18,10 @@
     updateComponent: PropTypes.func  // 閰嶇疆鏇存柊
   }
 
+  state = {
+    appType: sessionStorage.getItem('appType')
+  }
+
   componentDidMount () {
     MKEmitter.addListener('submitStyle', this.getStyle)
   }
@@ -54,9 +58,15 @@
 
   render() {
     const { config, defaultshow, hideSearch } = this.props
+    const { appType } = this.state
 
     let title = config.plot ? config.plot.title : config.wrap.title
     let show = true
+
+    if (!title && appType === 'mob' && config.type === 'card' && config.subtype === 'datacard' && config.action && config.action.length) {
+      title = ' '
+    }
+
     if (defaultshow === 'hidden') {
       if (!title && (!config.search || config.search.length === 0)) {
         show = false
diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
index 2f30000..cd01883 100644
--- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
@@ -145,7 +145,7 @@
       if (_config.plot.datatype === 'statistics') {
         if (_config.plot.ramp === 'true') {
           let _s = 'l(0) '
-          if (_config.plot.chartType === 'bar') {
+          if (_config.plot.chartType === 'bar' || (_config.plot.chartType === 'line' && _config.plot.rampDirection === 'vertical')) {
             _s = 'l(90) '
           }
           _config.plot.colors.forEach(item => {
@@ -183,7 +183,7 @@
       } else {
         if (_config.plot.ramp === 'true') {
           let _s = 'l(0) '
-          if (_config.plot.chartType === 'bar') {
+          if (_config.plot.chartType === 'bar' || (_config.plot.chartType === 'line' && _config.plot.rampDirection === 'vertical')) {
             _s = 'l(90) '
           }
           _config.plot.colors.forEach(item => {
@@ -531,6 +531,8 @@
     if (plot.repeat === 'average') {
       let _mdata = new Map()
       _cdata.forEach(item => {
+        if (!item[plot.Xaxis]) return
+
         vFields.forEach(col => {
           if (typeof(item[col.field]) !== 'number') {
             item[col.field] = parseFloat(item[col.field])
@@ -543,10 +545,15 @@
           }
         })
 
-        if (item[plot.Xaxis] && !_mdata.has(item[plot.Xaxis])) {
+        // dodge is not support linear attribute, please use category attribute! 鏃堕棿鏍煎紡
+        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
+          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
+        }
+
+        if (!_mdata.has(item[plot.Xaxis])) {
           item.$count = 1
           _mdata.set(item[plot.Xaxis], item)
-        } else if (item[plot.Xaxis]) {
+        } else {
           let _item = _mdata.get(item[plot.Xaxis])
           _item.$count++
           vFields.forEach(col => {
@@ -569,6 +576,8 @@
     } else if (plot.repeat === 'cumsum') {
       let _mdata = new Map()
       _cdata.forEach(item => {
+        if (!item[plot.Xaxis]) return
+
         vFields.forEach(col => {
           if (typeof(item[col.field]) !== 'number') {
             item[col.field] = parseFloat(item[col.field])
@@ -581,9 +590,13 @@
           }
         })
 
-        if (item[plot.Xaxis] && !_mdata.has(item[plot.Xaxis])) {
+        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
+          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
+        }
+
+        if (!_mdata.has(item[plot.Xaxis])) {
           _mdata.set(item[plot.Xaxis], item)
-        } else if (item[plot.Xaxis]) {
+        } else {
           let _item = _mdata.get(item[plot.Xaxis])
           vFields.forEach(col => {
             _item[col.field] += item[col.field]
@@ -604,7 +617,13 @@
     } else { // plot.repeat === 'unrepeat'
       let _mdata = new Map()
       _cdata.forEach(item => {
-        if (item[plot.Xaxis] && !_mdata.has(item[plot.Xaxis])) {
+        if (!item[plot.Xaxis]) return
+
+        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
+          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
+        }
+
+        if (!_mdata.has(item[plot.Xaxis])) {
           vFields.forEach(col => {
             if (typeof(item[col.field]) !== 'number') {
               item[col.field] = parseFloat(item[col.field])
@@ -657,6 +676,10 @@
       _cdata.forEach(item => {
         if (!item[plot.InfoType] || !item[plot.Xaxis]) return
 
+        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
+          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
+        }
+
         item.$uuid = item[plot.InfoType] + item[plot.Xaxis]
         if (typeof(item[plot.InfoValue]) !== 'number') {
           item[plot.InfoValue] = parseFloat(item[plot.InfoValue])
@@ -692,6 +715,10 @@
       _cdata.forEach(item => {
         if (!item[plot.InfoType] || !item[plot.Xaxis]) return
 
+        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
+          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
+        }
+
         item.$uuid = item[plot.InfoType] + item[plot.Xaxis]
 
         if (typeof(item[plot.InfoValue]) !== 'number') {
@@ -724,6 +751,10 @@
       let _mdata = new Map()
       _cdata.forEach(item => {
         if (!item[plot.InfoType] || !item[plot.Xaxis]) return
+
+        if (/^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(item[plot.Xaxis])) {
+          item[plot.Xaxis] = ' ' + item[plot.Xaxis]
+        }
 
         item.$uuid = item[plot.InfoType] + item[plot.Xaxis]
 
@@ -889,6 +920,9 @@
       let limit = chartColors.length
       _chart.color(_typefield, (key) => {
         if (plot.$colors.has(key)) {
+          if (plot.area === 'true' && plot.rampDirection === 'vertical') {
+            return plot.$colors.get(key).replace(/l\(9?0\) 0:|\s1:.*/ig, '')
+          }
           return plot.$colors.get(key)
         } else {
           colorIndex++
@@ -971,21 +1005,8 @@
   customrender = (data) => {
     const { plot, transfield } = this.state
     const ds = new DataSet()
+    const dv = ds.createView().source(data)
 
-    let _copydata = data
-    // dodge is not support linear attribute, please use category attribute! 鏃堕棿鏍煎紡
-    if (_copydata[0] && _copydata[0][plot.Xaxis] && /^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(_copydata[0][plot.Xaxis])) {
-      for (let i = 1; i < 12; i++) {
-        if (_copydata[i] && _copydata[i][plot.Xaxis] === _copydata[0][plot.Xaxis]) {
-          _copydata[i][plot.Xaxis] += ' '
-        } else {
-          break;
-        }
-      }
-      _copydata[0][plot.Xaxis] += ' '
-    }
-
-    const dv = ds.createView().source(_copydata)
     dv.transform({
       type: 'map',
       callback(row) {
@@ -1084,7 +1105,7 @@
         padding
       })
       const dst = new DataSet()
-      const dvt = dst.createView().source(_copydata)
+      const dvt = dst.createView().source(data)
   
       dvt.transform({
         type: 'fold',
@@ -1339,7 +1360,6 @@
     let _data = []
     let _valfield = 'value'
     let _typefield = 'key'
-
     let colorIndex = 0
 
     if (plot.datatype === 'statistics') {
@@ -1383,18 +1403,6 @@
       autoFit: true,
       height: plot.height
     })
-
-    // dodge is not support linear attribute, please use category attribute! 鏃堕棿鏍煎紡
-    if (_data[0] && _data[0][plot.Xaxis] && /^\d{4}-\d{2}-\d{2}(\s\d{2}:\d{2}:\d{2})?/.test(_data[0][plot.Xaxis])) {
-      for (let i = 1; i < 12; i++) {
-        if (_data[i] && _data[i][plot.Xaxis] === _data[0][plot.Xaxis]) {
-          _data[i][plot.Xaxis] += ' '
-        } else {
-          break;
-        }
-      }
-      _data[0][plot.Xaxis] += ' '
-    }
 
     chart.data(_data)
 

--
Gitblit v1.8.0