echarts axis nametextstyle overflow truncate not working HELP ASAP

py49o6xq  于 2022-12-31  发布在  Echarts
关注(0)|答案(5)|浏览(660)

Version

5.0.2

Steps to reproduce

I used this options

option = {
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
        show: true,
        name: 'bhemmmmmmmmmmmmmm gfdsmmmmmmmmmmmmmmmmmmmmmmmmmmm',
        type: 'value',
        nameTextStyle: {
            overflow: 'truncate',
            width: 10
        }
        
    },
    series: [{
        data: [150, 230, 224, 218, 135, 147, 260],
        type: 'line'
    }]
};

What is expected?

I am expecting the axis name to be truncated at a specific width

What is actually happening?

It is not getting truncated, I think the width property is not working

mm9b1k5b

mm9b1k5b1#

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that it contains a minimum reproducible demo and necessary images to illustrate. Otherwise, our committers will ask you to do so.

A minimum reproducible demo should contain as little data and components as possible but can still illustrate your problem. This is the best way for us to reproduce it and solve the problem faster.

You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org . Please attach the issue link if it's a technical question.

If you are interested in the project, you may also subscribe our mailing list .

Have a nice day! 🍵

cnh2zyt3

cnh2zyt32#

Am facing the same issue. Any solution mate?

whlutmcx

whlutmcx3#

The nameTruncate property will do this job. Noticed this proprety in /echarts/src/coord/axisDefault.js

option = {
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
        show: true,
        name: 'bhemmmmmmmmmmmmmm gfdsmmmmmmmmmmmmmmmmmmmmmmmmmmm',
        type: 'value',
        nameTruncate: {
            maxWidth: 100,
            ellipsis: '...',
        }
    },
    series: [{
        data: [150, 230, 224, 218, 135, 147, 260],
        type: 'line'
    }]
};

@TheLostDory

6jjcrrmo

6jjcrrmo5#

@Jagan-P & @jackielan66

nameTruncate works for me.
But i wanted to break the name, so it can appear as complete in next line ?

any solution for that?

nameTextStyle: { overflow: 'break-all' | 'break', width: 10 }

Not working either

相关问题