echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Feature] 折线图展示左右两边都为null的孤点

Open akiozhang opened this issue 2 years ago • 10 comments

What problem does this feature solve?

image 这种点,配置项该如何配置呢 设置symbol似乎无法完成想要的效果

What does the proposed API look like?

Uploading image.png…

akiozhang avatar Jun 17 '22 12:06 akiozhang

@gladcome It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗

TRANSLATED

TITLE

[Feature] The line chart shows the solitary points where the left and right sides are both null

BODY

What problem does this feature solve?

image At this point, how to configure the configuration item? Setting the symbol doesn't seem to accomplish the desired effect

What does the proposed API look like?

Uploading image.png…

echarts-bot[bot] avatar Jun 17 '22 12:06 echarts-bot[bot]

期望是不用hover也可以显示这样的效果

akiozhang avatar Jun 17 '22 12:06 akiozhang

这个数据在系列中应该为 null,然后在另一个系列中只放这个数据点

Ovilia avatar Jun 20 '22 06:06 Ovilia

@Ovilia 系列数据是data: [null, 3, null, 1,1,1,1,1,1],这样的情况下,希望3这个点能够默认展示为高亮,其余点hover高亮,目前的情况是3这个点没有hover的时候看不出是否存在

akiozhang avatar Jun 20 '22 10:06 akiozhang

symbolSize 支持回调函数的

Ovilia avatar Jun 21 '22 06:06 Ovilia

symbolSize 支持回调函数的

似乎并不能完成想要的效果 image

akiozhang avatar Jun 22 '22 03:06 akiozhang

showSymbol: false 当然没有啦。这样:

option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [150, 230, null, {value: 123, isDouble: true}, null, 147, 260],
      type: 'line',
      symbolSize: (data, param) => {
        return param.data && param.data.isDouble ? 20 : 0
      }
    }
  ]
};

Ovilia avatar Jun 22 '22 11:06 Ovilia

使用showSymbol: true 和 showAllSymbol: true 将所有数据点全部绘制,然后使用itemStyle: {opacity: 0}隐藏, 独立的无法连线的数据点设置为{value: **, itemStyle: {opacity: 1}} 其余数据点配置高亮状态,即可!!!

emphasis: { itemStyle: { opacity: 1 } }

缺点: 性能问题

数据量较大,tooltip渲染会因为showAllSymbol属性变得很差

期望有办法可以解决

akiozhang avatar Aug 03 '22 08:08 akiozhang

介绍一下目前的场景

  1. 数据量较大,且第一时间不需要展示 所以 showSymbol设置为false,由于存在空点(值为null),如果左右皆为null则看不到这个点
  2. 鼠标hover状态需展示symbol,设置x轴axisPointer展示
  3. 由于以上两点,导致某些左右皆为null的点无法展示,目前似乎没发单独为数据中的某个点设置symbol展示 发一下之前看到的类似场景:https://github.com/apache/echarts/issues/4748

akiozhang avatar Aug 03 '22 10:08 akiozhang

解决方案:

  1. 通过 dispatchAction 触发 首先计算出图表中需要高亮的数据点的dataIndex,作为数组触发highlight这个action 然后监听chart.on('downplay', (params) => { /*
  • 在这里通过params中的dataIndex判断是否是需要持续高亮的数据点
  • 将持续高亮的数据点再一次通过highlight点亮symbol
  • 如果有hidetip等影响symbol显示操作,需要在finished方法中设置相同的高亮symbol动作
  • 使用了finished方法后最好加锁,能够在影响symbol显示的方法中解锁即可 */ }) 效果如下: image 如有需要请联系

akiozhang avatar Aug 09 '22 03:08 akiozhang

解决方案: echarts3.8.5版本可以 利用markPoint 如果数值前后都是null 手动往markPoint 添加点

NAN0916 avatar Jan 11 '24 09:01 NAN0916