echarts [Feature] Add sortIndex for color callback of itemStyle when using realtimeSort

9rygscc1  于 5个月前  发布在  Echarts
关注(0)|答案(4)|浏览(111)

What problem does this feature solve?

I need constant color for series.itemStyle when using realtimeSort. Currently the color callback provide dataIndex for color picking. But it no params provide sorting info of data. I have to sort data manually before appling them to the bar chart. It makes realtimeSort useless for me.

What does the proposed API look like?

Add sortIndex to the params of series.itemStyle.color callback. It shows us sorting index for the currently data.

xdyibdwo

xdyibdwo1#

no params provide sorting info of data. I have to sort data manually before appling them to the bar chart

So you want to change items colors, instead of preserving them as in official example ?
Please make an effort to create Minimal Reproduction code.

ygya80vv

ygya80vv2#

@helgasoft ,I make some changes to the example:

yAxis: {
      type: 'category',
      inverse: true,
      max: 10,
      axisLabel: {
        show: true,
        fontSize: 14,
        formatter: function (value, idx, sortIdx) {
          const flag = sortIdx === 0 ? 'first' : sortIdx === 1 ? 'second' : 'normal';
          return '{' + flag  + '|' + value + '}' + '{flag|' + getFlag(value) + '}';
        },
        rich: {
          first: {
            color: '#ffd700'
          },
          second: {
            color: 'c0c0c0',
          },
          normal: {},
          flag: {
            fontSize: 25,
            padding: 5
          }
        }
      },
      animationDuration: 300,
      animationDurationUpdate: 300
    },

This always set specific color for the first and the second.

vq8itlhq

vq8itlhq3#

This always set specific color for the first and the second.

cannot replicate, sortIdx is null, I still do not understand what you are trying to accomplish

ifsvaxew

ifsvaxew4#

@helgasoft I want echarts to implement sortIdx which give me the current sorting info data in realtimeSort: true .
For the official demo, in my case, the first and the second city should be always using gold and silver color. Other cities keeping using their colors.

相关问题