Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inconsistencies between yAxis.axisLabel and yAxis.axisPointer.label formatters #8294

Closed
astik opened this issue May 6, 2018 · 1 comment
Closed
Labels
stale Inactive for a long time. Will be closed in 7 days.

Comments

@astik
Copy link

astik commented May 6, 2018

inconsistencies between yAxis.axisLabel and yAxis.axisPointer.label formatters with string configuration (interpolation seems to give different results)

Version & Environment [版本及环境]

  • ECharts version [ECharts 版本]: 4.x
  • Browser version [浏览器类型和版本]: tested with chrome 66.0.3359.139 and firefox 59.0.2, but i don't think it matters
  • OS Version [操作系统类型和版本]: tested with osx 10.13.3, but i don't think it matters

Expected behaviour [期望结果]

Formatter with same configuration should give the same result for both labels (yAxis.axisLabel and yAxis.axisPointer.label).

ECharts option [ECharts配置项]

option = {
    tooltip: {
        trigger: 'axis',
			axisPointer: {
				type: 'cross'
			}
    },
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
        type: 'value',
        axisLabel: {
            formatter: '{value}'
        },
        axisPointer: {
            label:{
                formatter: '{value}'
            }
        }
    },
    series: [
        {
            name:'A',
            type:'line',
            data:[120000.5, 132000.5, 101000.5, 134000.5, 90000.5, 230000.5, 210000.5]
        },
        {
            name:'B',
            type:'line',
            data:[220000.5, 282000.5, 201000.5, 234000.5, 290000.5, 430000.5, 410000.5]
        }
    ]
};

With this configuration, you'll end-up with :

  • yAxis.axisLabel will display "120000.5" for 120000.5
  • yAxis.axisPointer.label will display "120,000.5" for 120000.5

To get a consistent display, you'll need to have this configuration :

option = {
    tooltip: {
        trigger: 'axis',
	axisPointer: {
		type: 'cross',
        },
        formatter: function formatArrayValue(value) {
            var result = value.map(function(v){
                return `${v.marker} ${v.seriesName} : ${v.value}`
            })
            return `${value[0].name}<br />${result.join('<br />')}`
        }
    },
    xAxis: {
        type: 'category',
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    yAxis: {
        type: 'value',
        axisLabel: {
            formatter: '{value}'
        },
        axisPointer: {
            label:{
                formatter: function(a){return a.value}
            }
        }
    },
    series: [
        {
            name:'A',
            type:'line',
            data:[120000.5, 132000.5, 101000.5, 134000.5, 90000.5, 230000.5, 210000.5]
        },
        {
            name:'B',
            type:'line',
            data:[220000.5, 282000.5, 201000.5, 234000.5, 290000.5, 430000.5, 410000.5]
        }
    ]
};
@stale
Copy link

stale bot commented May 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Inactive for a long time. Will be closed in 7 days.
Projects
None yet
Development

No branches or pull requests

1 participant