echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Highlighting the clicked month

Open vikramkalta opened this issue 8 years ago • 15 comments

test

I want to get the selected month by user highlighted!! as you can see in the image i have attached. I have come close by using brush, but still could not acheive it completely. When I dispatch an action, lets say I pass ['Mar', 'Apr'] to coordRange property, and it makes a brush between Mar and April, I want it to be highlighted exactly April if user selected April. Thanks

One-line summary [问题简述]

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]:
  • Browser version [浏览器类型和版本]:
  • OS Version [操作系统类型和版本]:

Expected behaviour [期望结果]

ECharts option [ECharts配置项]

option = {

}

Other comments [其他信息]

vikramkalta avatar Apr 15 '18 13:04 vikramkalta

Try using the markArea component to highlight the area

pissang avatar Apr 16 '18 04:04 pissang

@vikramkalta did you solve your problem?

thomaspessato avatar May 29 '18 12:05 thomaspessato

@pissang Hi, thanks for the reply, sorry about the late reply. I will definitely try using markArea and update. (Im heavily using echarts for a project, little bit help from the inside people would be great).

@thomaspessato i solved my problem using graphic and positioning graphic using offsetX which i get with every click, although if u resize the browser, it does not stay at that selected month anymore.

vikramkalta avatar May 29 '18 15:05 vikramkalta

@vikramkalta I managed to change label style after click, for example:

this.chart.on('click', (params) => {
    params.event.target.style.fontWeight = "bold";
    params.event.target.style.textFill = "#000";
})

This related to the point clicked... but would be nice if we on click, since this doesnt change data, just label / point / area style.

I saw that people were using setOption() for this... but don't know how to do this, exactly :/

thomaspessato avatar May 29 '18 15:05 thomaspessato

@thomaspessato I guess u are trying to just emphasize the circle when it is clicked!! I reworked on it today and and found exactly what i was looking for, so i made a custom series with same rectangular figure, and position it inside renderItem property.

renderItem: (params: any, api: any) => { const categoryIndex = api.value(0); console.log('category', api.coord([api.value(0), maxVal])); const start = api.coord([api.value(0), maxVal]);

            if (params.dataIndex === this.monthIndex) {
              return {
                type: 'group',
                children: [
                  {
                    type: 'rect',
                    shape: {
                      width: '30',
                      height: 110
                    },
                    position: newStart,
                    top: this.options.grid.top,
                    style: { fill: 'rgba(255,255,0,0.3)' }
                  }
                ]
              };
            }

          },

Phewwww... even if screen sizez changes the graphic does not move a inch.....

vikramkalta avatar May 31 '18 18:05 vikramkalta

@vikramkalta that's nice! I'm happy that you could solve this! 💯

"I guess u are trying to just emphasize the circle when it is clicked!!"

yeah, but I was having a hard time with this because when I hover my cursor to another point it emphasize that other point and my previously emphasized point is just gone :/ Do you have any tips for this?

thomaspessato avatar May 31 '18 19:05 thomaspessato

set emphasize to false in the options or refer the docs, and set emphasize for each click. or you can dispatch an action on a click and that would do the same!! dispatchAction({ type: 'highlight', // optional; series index; could be an array of multiple series seriesIndex?: number|Array, // optional; series name; could be an array of multiple series seriesName?: string|Array, // options are index of data dataIndex?: number, // options are data name name?: string })

refer the api section in echarts website

vikramkalta avatar May 31 '18 19:05 vikramkalta

but in order to keep the previous clicked circle also in the same state, i had not tried that yet!!

vikramkalta avatar May 31 '18 19:05 vikramkalta

@vikramkalta Damn!! That was so obvious... thanks for pointing that out!

thomaspessato avatar May 31 '18 19:05 thomaspessato

I could not find emphasize on click, but will search for that

thomaspessato avatar May 31 '18 19:05 thomaspessato

@thomaspessato I have tried dispatching action, it works for a click, on every click just pass the ev.dataIndex to dataIndex property https://ecomfe.github.io/echarts-doc/public/en/api.html#action

vikramkalta avatar May 31 '18 19:05 vikramkalta

gonna try this!

thomaspessato avatar May 31 '18 20:05 thomaspessato

but automatically triggered highlight event cannot be triggered event. For example, when I switch automatically, the mouse moves up. Trigger the default highlight. But did not trigger the highlight event. So, I think there are other ways to handle the mouseover event. (sorry, my english is poor) https://codepen.io/Carl_su/pen/zyzWQQ

Ppsj avatar Dec 26 '18 02:12 Ppsj

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 25 '20 11:12 stale[bot]

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!

github-actions[bot] avatar Sep 03 '21 21:09 github-actions[bot]