首页图表自定义颜色错误修复

feat/task1-c-wallet
gongfuxiang 2024-01-19 21:54:22 +08:00
parent 4e28c57777
commit ceddb30c39
1 changed files with 60 additions and 51 deletions

View File

@ -116,24 +116,27 @@ function EchartsStyle (data, radius) {
} }
var new_data = data.map(function (item, index) { var new_data = data.map(function (item, index) {
var item_style = { if((gradient_color[index] || null) != null) {
itemStyle: { var item_style = {
borderRadius: borderRadius, // 设置柱状图边框的圆角大小,单位为像素 itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ borderRadius: borderRadius, // 设置柱状图边框的圆角大小,单位为像素
offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983 color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
}, { offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983
offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9 }, {
}]) offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9
}, }])
areaStyle: { },
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ areaStyle: {
offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983 color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
}, { offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983
offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9 }, {
}]) offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9
}, }])
},
}
return Object.assign({}, item, item_style);
} }
return Object.assign({}, item, item_style); return item;
}); });
return new_data; return new_data;
}; };
@ -556,24 +559,27 @@ function EchartsNewUser (name_arr, data) {
] ]
var borderRadius = [40, 40, 0, 0]; var borderRadius = [40, 40, 0, 0];
var new_data = data.map(function (item, index) { var new_data = data.map(function (item, index) {
var item_style = { if((gradient_color[index] || null) != null) {
itemStyle: { var item_style = {
borderRadius: borderRadius, // 设置柱状图边框的圆角大小,单位为像素 itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ borderRadius: borderRadius, // 设置柱状图边框的圆角大小,单位为像素
offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983 color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
}, { offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983
offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9 }, {
}]) offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9
}, }])
areaStyle: { },
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ areaStyle: {
offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983 color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
}, { offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983
offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9 }, {
}]) offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9
}, }])
},
}
return Object.assign({}, item, item_style);
} }
return Object.assign({}, item, item_style); return item;
}); });
var chart = echarts.init(document.getElementById('echarts-new-user'), 'macarons'); var chart = echarts.init(document.getElementById('echarts-new-user'), 'macarons');
var option = { var option = {
@ -653,24 +659,27 @@ function EchartsBuyUser (name_arr, data) {
] ]
var borderRadius = [40, 40, 0, 0]; var borderRadius = [40, 40, 0, 0];
var new_data = data.map(function (item, index) { var new_data = data.map(function (item, index) {
var item_style = { if((gradient_color[index] || null) != null) {
itemStyle: { var item_style = {
borderRadius: borderRadius, // 设置柱状图边框的圆角大小,单位为像素 itemStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ borderRadius: borderRadius, // 设置柱状图边框的圆角大小,单位为像素
offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983 color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
}, { offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983
offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9 }, {
}]) offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9
}, }])
areaStyle: { },
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ areaStyle: {
offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983 color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
}, { offset: 0, color: gradient_color[index][0] // 渐变色从正上方开始,颜色为#42b983
offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9 }, {
}]) offset: 1, color: gradient_color[index][1] // 指100%处的颜色,颜色为#4a82c9
}, }])
},
}
return Object.assign({}, item, item_style);
} }
return Object.assign({}, item, item_style); return item;
}); });
var chart = echarts.init(document.getElementById('echarts-buy-user'), 'macarons'); var chart = echarts.init(document.getElementById('echarts-buy-user'), 'macarons');
var option = { var option = {