Skip to content

Commit

Permalink
[fix]去掉多要素颜色和seriesName修改 立方体颜色修改 review by qiw
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiao-supermap committed Nov 22, 2023
1 parent eb834f5 commit 6488d0c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 89 deletions.
42 changes: 1 addition & 41 deletions src/common/chart/ChartMixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,6 @@ export default {
isShow: {
type: Boolean,
default: true
},
filterCategoryValue: {
type: [Number, String],
default: undefined
}
},
data() {
Expand Down Expand Up @@ -559,42 +555,6 @@ export default {
this.datasetChange = false;
// 设置echartOptions
this.echartOptions = this._optionsHandler(echartOptions, options);
const setColorType = ['2.5Bar', 'bar'];
let serieType;
if (this.options && this.options.series && this.options.series[0]) {
serieType = this.options.series[0].type;
}
if (setColorType.includes(serieType)) {
this.setSeriesColor();
}
this.setSeriesName();
});
},
setSeriesColor() {
const colorGroup = getMultiColorGroup(this.colorGroupsData, this.colorNumber);
const firstSeriesName = this.echartOptions.series[0].name;
let SeserieNameTag = firstSeriesName.includes('-') ? firstSeriesName.split('-')[1] : firstSeriesName;
let colorIndex = 0;
this.echartOptions.series.forEach(serie => {
const serieName = serie.name.includes('-') ? serie.name.split('-')[1] : serie.name;
if (SeserieNameTag !== serieName) {
SeserieNameTag = serieName;
colorIndex += 1;
}
serie.itemStyle = serie.itemStyle || {};
serie.itemStyle.color = colorGroup[colorIndex];
this.$set(serie, 'itemStyle', { color: colorGroup[colorIndex] });
});
},
setSeriesName() {
if (!this.echartOptions.series && !this.echartOptions.series.length) {
return;
}
this.echartOptions.series.forEach(serie => {
const serieName = serie.name.includes('-') ? serie.name.split('-')[1] : serie.name;
if (!this.filterCategoryValue && this.multipleYField) {
serie.name = serieName;
}
});
},
_optionsHandler(options, dataOptions, dataZoomChanged) {
Expand Down Expand Up @@ -855,7 +815,7 @@ export default {
return (params, api) => {
seriesSpace = !parallelShow ? 0 : seriesSpace;
const location = api.coord([api.value(0), api.value(1)]);
let fillColor = !colorIndex ? defaultColor : colorGroup[colorIndex];
let fillColor = (!colorIndex && defaultColor) ? defaultColor : colorGroup[colorIndex];
if (_this.highlightOptions && _this.highlightOptions.length > 0) {
const matchData = _this.highlightOptions.find(
item => item.seriesIndex.includes(params.seriesIndex) && item.dataIndex === params.dataIndex
Expand Down
48 changes: 0 additions & 48 deletions src/common/chart/__tests__/ChartMixin.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,52 +650,4 @@ describe('Chart Mixin Component', () => {
expect(wrapper.emitted().click.length).toBe(1);
expect(wrapper.emitted().click[0]).toEqual([params]);
});

it('setSeriesColor', async done => {
const serieItem = {
name: 'sale',
emphasis: {
itemStyle: {}
},
itemStyle: {
barBorderRadius: [0, 15, 15, 0]
},
stack: 0,
type: 'bar',
barWidth: 10,
data: [22, 65, 86, 48, 43, 53, 34, 33, 24]
};
const series = [serieItem];
const options = {
xAxis: yAxis,
yAxis: xAxis,
legend,
series
};
wrapper = factory({
options
});
expect(wrapper.vm.xBar).toBeTruthy();
await wrapper.setProps({
options: {
...options,
series: [
{
...serieItem,
label: {
normal: {
show: true,
position: 'center',
smart: true
}
}
}
]
}
});
expect(wrapper.vm.echartOptions).toStrictEqual(wrapper.vm.parseOptions);
wrapper.vm.setSeriesColor();
expect(wrapper.vm.echartOptions.series[0].itemStyle.color).toEqual('#d53e4f');
done();
});
});

0 comments on commit 6488d0c

Please sign in to comment.