为 EChart 项目添加突出显示样式?

huangapple go评论110阅读模式
英文:

Adding a highlight style to EChart Items?

问题

在这一行的echart中,我希望每个符号(黑色点)在鼠标悬停在符号上时变成白色,并带有蓝色边框。

这是图表的配置。

  1. data: this.data,
  2. silent: true,
  3. sampling: 'average',
  4. symbolSize: 12,
  5. symbol: 'circle',
  6. type: 'line',
  7. itemStyle: {
  8. color: 'rgba(0,0,0, 0.6)',
  9. },
  10. lineStyle: {
  11. width: 5,
  12. color: 'rgba(0,0,0,0.4)',
  13. },

itemStyle 控制符号的颜色。如何添加悬停效果呢?

我以为添加 emphasis 会起作用,所以我尝试了以下两种配置:

嵌套在 Emphasis 中的 Item Style

  1. emphasis: {
  2. itemStyle: {
  3. color: 'white',
  4. borderColor: 'blue',
  5. borderWidth: 2,
  6. },
  7. },

嵌套在 Item Style 中的 Emphasis

  1. itemStyle: {
  2. color: 'rgba(0,0,0, 0.6)',
  3. emphasis: {
  4. color: 'white',
  5. borderColor: 'blue',
  6. borderWidth: 2,
  7. },
  8. },

但是都没有任何效果。

英文:

In this line echart I'd like each symbol (The black dot) to turn white with a blue border when the symbol is hovered over.

This is the configuration for the chart.

  1. data: this.data,
  2. silent: true,
  3. sampling: 'average',
  4. symbolSize: 12,
  5. symbol: 'circle',
  6. type: 'line',
  7. itemStyle: {
  8. color: 'rgba(0,0,0, 0.6)',
  9. },
  10. lineStyle: {
  11. width: 5,
  12. color: 'rgba(0,0,0,0.4)',
  13. },

The itemStyle controls the color of the symbol. How do we add a hover effect to that?

I thought adding emphasis would do it and so I tried both of these configurations:

Item Style Nested in Emphasis

  1. emphasis: {
  2. itemStyle: {
  3. color: 'white',
  4. borderColor: 'blue',
  5. borderWidth: 2,
  6. },
  7. },

Emphasis Nested in Item Style

  1. itemStyle: {
  2. color: 'rgba(0,0,0, 0.6)',
  3. emphasis: {
  4. color: 'white',
  5. borderColor: 'blue',
  6. borderWidth: 2,
  7. },
  8. },

But neither has any effect.

答案1

得分: 1

我已经搞清楚了... silent 选项被设置为 true。在这种情况下,tooltip 不会显示,并且 emphasis 被关闭。

这是一个带有提示和强调的工作演示。

英文:

OK ... Figured it out ... The silent option was set to true. When that's the case the tooltip does not get displayed and the emphasis is switched off.

This is a working demo with the tooltip and the emphasis.

huangapple
  • 本文由 发表于 2023年6月19日 22:41:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/76507700.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定