From dc056d66291ec1151e728488f7c51466938621e1 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期三, 21 七月 2021 18:36:44 +0800 Subject: [PATCH] 2021-07-21 --- src/menu/components/chart/antv-bar/index.jsx | 118 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 105 insertions(+), 13 deletions(-) diff --git a/src/menu/components/chart/antv-bar/index.jsx b/src/menu/components/chart/antv-bar/index.jsx index c878654..19cd40e 100644 --- a/src/menu/components/chart/antv-bar/index.jsx +++ b/src/menu/components/chart/antv-bar/index.jsx @@ -246,8 +246,27 @@ // chart.axis(X_axis, { label: { style: { fill: color } }, tickLine: {style: { stroke: color }}, line: { style: { stroke: color } } }) // chart.axis('value', { grid: { line: { style: { stroke: color } }}, label: { style: { fill: color } } }) - chart.axis(X_axis, { label: { style: { fill: color } } }) - chart.axis('value', { label: { style: { fill: color } } }) + + let xc = {label: { style: { fill: color } }} + let yc = {label: { style: { fill: color } }} + if (plot.grid === 'hidden') { + yc.grid = null + } + if (plot.y_line === 'show') { + yc.line = {style: { stroke: '#D1D2CE' }} + } + if (plot.lineColor) { + xc.tickLine = {style: { stroke: plot.lineColor }} + xc.line = { style: { stroke: plot.lineColor } } + if (yc.grid !== null) { + yc.grid = { line: { style: { stroke: plot.lineColor } }} + } + if (yc.line) { + yc.line = { style: { stroke: plot.lineColor } } + } + } + chart.axis(X_axis, xc) + chart.axis('value', yc) if (plot.coordinate !== 'polar') { chart.scale(X_axis, { @@ -369,7 +388,10 @@ } if (plot.area === 'true') { - let area = chart.area().shape(plot.shape || 'smooth').position(`${X_axis}*value`).tooltip(false) + let area = chart.area().position(`${X_axis}*value`).tooltip(false) + if (plot.shape === 'smooth') { + area.shape('smooth') + } if (plot.colors && plot.colors.length > 0) { let limit = chartColors.length area.color('key', (key) => { @@ -451,6 +473,9 @@ let axisIndex = 0 let hasBar = false + plot.$paddingLeft = 30 + plot.$paddingRight = 30 + plot.customs.forEach(item => { item.name = transfield[item.type] || item.type item.chartType = item.shape ? (item.shape[0] || 'bar') : 'bar' @@ -471,10 +496,39 @@ if (item.axis === 'true' && axisIndex < 2) { if (axisIndex === 0) { // item.axis = { grid: {line: { style: { stroke: color } }}, title: { style: { fill: color } }, label: {style: { fill: color }} } - item.axis = { title: { style: { fill: color } }, label: {style: { fill: color }} } + item.axis = { label: {style: { fill: color }} } + if (item.title !== 'false') { + item.axis.title = { style: { fill: color } } + plot.$paddingLeft = 50 + } + if (plot.grid === 'hidden') { + item.axis.grid = null + } + if (plot.y_line === 'show') { + item.axis.line = {style: { stroke: '#D1D2CE' }} + } + if (plot.lineColor) { + if (item.axis.grid !== null) { + item.axis.grid = { line: { style: { stroke: plot.lineColor } }} + } + if (item.axis.line) { + item.axis.line = { style: { stroke: plot.lineColor } } + } + } + fields.unshift(item) } else { - item.axis = { grid: null, title: {style: { fill: color }}, label: {style: { fill: color }} } + item.axis = { grid: null, label: {style: { fill: color }} } + if (item.title !== 'false') { + item.axis.title = { style: { fill: color } } + plot.$paddingRight = 60 + } + if (plot.y_line === 'show') { + item.axis.line = {style: { stroke: '#D1D2CE' }} + } + if (plot.lineColor && item.axis.line) { + item.axis.line = { style: { stroke: plot.lineColor } } + } fields.splice(1, 0, item) } axisIndex++ @@ -508,11 +562,7 @@ } if (!Bar_axis.length) { - if (axisIndex === 2) { - padding = [10, 50, 30, 50] - } else if (axisIndex === 1) { - padding = [10, 30, 30, 50] - } + padding = [10, plot.$paddingRight, 30, plot.$paddingLeft] } const chart = new Chart({ @@ -522,7 +572,13 @@ }) // chart.axis(plot.Xaxis, { label: { style: { fill: color } }, tickLine: {style: { stroke: color }}, line: { style: { stroke: color } } }) - chart.axis(plot.Xaxis, { label: { style: { fill: color } } }) + + let xc = {label: { style: { fill: color } }} + if (plot.lineColor) { + xc.tickLine = {style: { stroke: plot.lineColor }} + xc.line = { style: { stroke: plot.lineColor } } + } + chart.axis(plot.Xaxis, xc) if (!hasBar) { chart.scale(plot.Xaxis, { @@ -605,6 +661,23 @@ nice: true, range: [0, 0.9] }) + + let yc = {label: { style: { fill: color } }} + if (plot.grid === 'hidden') { + yc.grid = null + } + if (plot.y_line === 'show') { + yc.line = {style: { stroke: '#D1D2CE' }} + } + if (plot.lineColor) { + if (yc.grid !== null) { + yc.grid = { line: { style: { stroke: plot.lineColor } }} + } + if (yc.line) { + yc.line = { style: { stroke: plot.lineColor } } + } + } + view1.axis('value', yc) view1.legend(false) @@ -896,8 +969,27 @@ // chart.axis(X_axis, { label: { style: { fill: color } }, tickLine: {style: { stroke: color }}, line: { style: { stroke: color } } }) // chart.axis('value', { grid: { line: { style: { stroke: color } }}, label: { style: { fill: color } } }) - chart.axis(X_axis, { label: { style: { fill: color } } }) - chart.axis('value', { label: { style: { fill: color } } }) + + let xc = {label: { style: { fill: color } }} + let yc = {label: { style: { fill: color } }} + if (plot.grid === 'hidden') { + yc.grid = null + } + if (plot.y_line === 'show') { + yc.line = {style: { stroke: '#D1D2CE' }} + } + if (plot.lineColor) { + xc.tickLine = {style: { stroke: plot.lineColor }} + xc.line = { style: { stroke: plot.lineColor } } + if (yc.grid !== null) { + yc.grid = { line: { style: { stroke: plot.lineColor } }} + } + if (yc.line) { + yc.line = { style: { stroke: plot.lineColor } } + } + } + chart.axis(X_axis, xc) + chart.axis('value', yc) chart.scale('value', { nice: true, -- Gitblit v1.8.0