apache / apache/echarts

[Feature] Need different color for each brush marker.

Open
#18,191 1 comment 1 reaction 1 assignee Claimed by @Ovilia View on GitHub
en new-feature
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

### What problem does this feature solve?

Get different color for each brush area like given in the example below -

![image](https://user-images.githubusercontent.com/93267110/213419704-934674c9-d39c-4bc4-a8c7-2df65884fce7.png)

Right now we have option to set color for brush component but it is applicable for all brush.

We need feature to provide diff colors for each area.

Below is the code that we have tried for achieving above functionality.

function func(x) {
x /= 10;
return Math.random() * 22
}
function generateData() {
let data = [];
for (let i = 0; i <= 10; i += 0.1) {
data.push([i, func(i)]);
}
return data;
}
let colors = ['red', 'green','yellow', 'blue'];
option = {
animation: false,
toolbox: {
feature: {
dataZoom: {
yAxisIndex: false
},
brush: {
type: ['lineX', 'clear', 'keep']
},
}
},
brush: {
xAxisIndex: 'all',
brushLink: 'all',
brushStyle: {
color: 'white',
},
outOfBrush: {
colorAlpha: 0.1
}
},
graphic: {
elements: [],
},
grid: {
top: 100,
left: 50,
right: 40,
bottom: 50
},
xAxis: {
minorTick: {
show: true
},
minorSplitLine: {
show: true
}
},
yAxis: {
minorTick: {
show: true
},
minorSplitLine: {
show: true
}
},
series: [
{
type: 'line',
showSymbol: false,
clip: true,
data: generateData()
}
]
};

let count = 0;

myChart.on('brushEnd', function() {
let newOption = option;
newOption.brush.brushStyle.color = colors[count],
count = count + 1;
myChart.setOption(newOption);
})

### What does the proposed API look like?

NaN

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.