You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/07/11 15:10:35 UTC
[GitHub] [incubator-echarts] EfkanKnz edited a comment on issue #8694: How
to highlight selected data point.
EfkanKnz edited a comment on issue #8694: How to highlight selected data point.
URL: https://github.com/apache/incubator-echarts/issues/8694#issuecomment-510525854
Hi, for those who might have the same issue (but with **LINE echarts**), I found an alternative to "highlight" a selected point. I use `markPoint` option.
When we click on a point on the chart, we create a new mark with the coordinates (x,y) of this point itself.
Angular files:
**component.html**
```
<div
echarts
class="echart"
[autoResize]="true"
[options]="chartOption"
(chartClick)="onChartClick($event)"
(chartInit)="onChartInit($event)"
>
</div>
```
**component.ts**
```
onChartInit(ec: any): void {
this.echartsInstance = ec;
}
onChartClick(event: any): void {
if (event) {
this.resetAllMarkPoint();
/* My structure is like this
this.chartOption.series = [
{
name: 'firstLine',
type: 'line',
symbolSize: 4,
smooth: true,
markPoint: { data: [] },
data: [[1, 10],[2,20],[3,30]],
connectNulls: true
}
];
*/
this.chartOption.series[event.seriesIndex]['markPoint'].data = [
{ value: event.value[1], xAxis: event.dataIndex, yAxis: event.value[1] }
];
this.refresh();
}
}
resetAllMarkPoint(): void {
this.chartOption.series.forEach(element => {
element['markPoint'].data = [];
});
}
refresh(): void {
if (this.echartsInstance) {
this.echartsInstance.setOption(this.chartOption, true);
}
}
```
**component.scss**
```
.echart {
height: 400px;
}
```
Maybe it can help someone ;)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org