echarts icon indicating copy to clipboard operation
echarts copied to clipboard

Display bar chart with thumbnails in yAxis instead of label

Open akvaliya opened this issue 8 years ago • 10 comments

I am using this library in my project.

I want to display bar chart with thumbnails. I need to display log of banners.

So i will need chart like below just images in axis.

enter image description here

I am not sure it is possible or not with this library.

If anyone has any ideas then please let me know.

akvaliya avatar Jul 26 '18 14:07 akvaliya

https://echarts.apache.org/tutorial.html#Rich%20Text

luguokong avatar Jul 27 '18 07:07 luguokong

It works only with data without space & some characters(-,_). Below is my yAxis options

yAxis: {
        type: 'category',
        inverse: true,
        data: ['Full Sunny', 'Cloudy', 'Showers'],
        axisLabel: {
            formatter: function (value) {
                return '{value|' + value + '}  {' + value + '| }';
            },
            margin: 20,
            rich: {
                value: {
                    lineHeight: 30,
                    align: 'center'
                },
                'Full Sunny': {
                    height: 40,
                    align: 'center',
                    backgroundColor: {
                        image: weatherIcons.Sunny
                    }
                },
                'Cloudy': {
                    height: 40,
                    align: 'center',
                    backgroundColor: {
                        image: weatherIcons.Cloudy
                    }
                },
                'Showers': {
                    height: 40,
                    align: 'center',
                    backgroundColor: {
                        image: weatherIcons.Showers
                    }
                }
            }
        }
    }

This is result chart

As you can see images displaying in "Cloudy" & "Showers" (without space). But image is not displaying in 'Full Sunny'.

What am i missing here?

akvaliya avatar Aug 02 '18 15:08 akvaliya

@akvaliya You're right. rich doesn't support space in name. We think it make sense since variable name cannot contain space in JavaScript. In which case must you have space in rich name?

Ovilia avatar Aug 14 '18 02:08 Ovilia

Variable can contain space or any character in javascript. In json key-value pair can be like var temp = {"Full-Sunny" : any_value}. Any type of string can be key. it can be accessed by temp["Full-Sunny"].

I have a data with string with space like i have mentioned in question.

Will this issue be resolved in any release? This is a critical bug.

akvaliya avatar Aug 14 '18 12:08 akvaliya

@akvaliya How about converting your string to remove these characters? Currently, /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g is used for detecting the key. See: https://github.com/ecomfe/zrender/blob/0cc622196d8665f40d02b6156450cc7a87fe3a67/src/contain/text.js#L15 We will change it if we find the reason is common need for others. Thanks!

Ovilia avatar Aug 15 '18 03:08 Ovilia

Yes i can remove characters. But what about space? I have data array of companies name. I can't remove space from company name.
I want to display company logo with name. How can i achieve this?

akvaliya avatar Aug 15 '18 11:08 akvaliya

Does 'Company Name {icon|}' work for you?

Ovilia avatar Aug 27 '18 02:08 Ovilia

@Ovilia I want to display company name with icon like i displayed in image in question. I need to know formatter for it. Current formatter is not working with company name containing space or any special characters(like dash -).

akvaliya avatar Aug 27 '18 12:08 akvaliya

See http://www.echartsjs.com/gallery/editor.html?c=treemap-obama around line 135 params.name

Ovilia avatar Aug 27 '18 13:08 Ovilia

See http://www.echartsjs.com/gallery/editor.html?c=treemap-obama around line 135 params.name

Is this still open? The provided URL just redirects me to the root

ardey26 avatar Jul 19 '24 13:07 ardey26