refactor: 颜色优化

This commit is contained in:
junjun 2022-03-10 10:10:07 +08:00
parent 8b6dc5c0fa
commit b24a46e6f6
12 changed files with 16 additions and 16 deletions

View File

@ -25,7 +25,7 @@ export function baseBarOption(chart_option, chart) {
const y = chart.data.series[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {
@ -88,7 +88,7 @@ export function horizontalBarOption(chart_option, chart) {
const y = chart.data.series[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {

View File

@ -40,7 +40,7 @@ export function baseFunnelOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// y.type = 'funnel'
chart_option.series[0].data.push(y)

View File

@ -63,7 +63,7 @@ export function baseGaugeOption(chart_option, chart) {
for (let i = 0; i < arr.length; i++) {
const ele = arr[i]
const p = parseInt(ele) / 100
range.push([p, hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)])
range.push([p, hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)])
if (!flag && per <= p) {
flag = true
index = i
@ -73,7 +73,7 @@ export function baseGaugeOption(chart_option, chart) {
index = arr.length
}
range.push([1, hexColorToRGBA(customAttr.color.colors[arr.length % 9], customAttr.color.alpha)])
range.push([1, hexColorToRGBA(customAttr.color.colors[arr.length % customAttr.color.colors.length], customAttr.color.alpha)])
chart_option.series[0].axisLine = {
lineStyle: {
color: range

View File

@ -88,12 +88,12 @@ export function baseGaugeOptionAntV(plot, container, chart, action) {
options.indicator = {
pointer: {
style: {
stroke: theme.styleSheet.paletteQualitative10[index % 9]
stroke: theme.styleSheet.paletteQualitative10[index % theme.styleSheet.paletteQualitative10.length]
}
},
pin: {
style: {
stroke: theme.styleSheet.paletteQualitative10[index % 9]
stroke: theme.styleSheet.paletteQualitative10[index % theme.styleSheet.paletteQualitative10.length]
}
}
}

View File

@ -25,7 +25,7 @@ export function baseLineOption(chart_option, chart) {
const y = chart.data.series[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {

View File

@ -73,7 +73,7 @@ export function baseMapOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
// y.itemStyle = {
// color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha),
// color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha),
// borderRadius: 0
// }
chart_option.series[0].data.push(y)

View File

@ -27,7 +27,7 @@ export function baseMixOption(chart_option, chart) {
y.type = y.type ? y.type : 'bar'
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {

View File

@ -43,7 +43,7 @@ export function baseMixOptionAntV(plot, container, chart, action) {
const o = {
type: '',
options: {
color: colors[i % 9],
color: colors[i % colors.length],
data: d.data,
xField: 'field',
yField: 'value',

View File

@ -41,7 +41,7 @@ export function basePieOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha),
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha),
borderRadius: 0
}
y.type = 'pie'
@ -94,7 +94,7 @@ export function rosePieOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha),
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha),
borderRadius: customAttr.size.pieRoseRadius
}
y.type = 'pie'

View File

@ -33,7 +33,7 @@ export function baseRadarOption(chart_option, chart) {
}
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// label
if (customAttr.label) {

View File

@ -30,7 +30,7 @@ export function baseScatterOption(chart_option, chart, terminal = 'pc') {
const y = chart.data.series[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// size
if (customAttr.size) {

View File

@ -49,7 +49,7 @@ export function baseTreemapOption(chart_option, chart) {
y.name = chart.data.x[i]
// color
y.itemStyle = {
color: hexColorToRGBA(customAttr.color.colors[i % 9], customAttr.color.alpha)
color: hexColorToRGBA(customAttr.color.colors[i % customAttr.color.colors.length], customAttr.color.alpha)
}
// y.type = 'treemap'
chart_option.series[0].data.push(y)