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

Y轴type为对数轴,Y轴数据有时显示格式错误,不再是对数的成了小数 #3161

Closed
hejinenPrivate opened this issue May 7, 2016 · 8 comments
Labels
Milestone

Comments

@hejinenPrivate
Copy link

hejinenPrivate commented May 7, 2016

问题简述 (One-line summary)

当Y轴type为对数轴,Y轴数据有时显示格式错误,Y轴上的值显示成了小数。

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version):3.0
  • 浏览器类型和版本 (Browser version):所有浏览器,和浏览器无关,我用的是google和火狐
  • 操作系统类型和版本 (OS Version):win7

重现步骤 (Steps to reproduce)

1.打开官网对数轴实例:http://echarts.baidu.com/demo.html#line-log
2.将3条折线的值改成如下这样,问题出现Y轴的值不在是对数的成了小数:

series: [
        {
            name: '3的指数',
            type: 'line',
            data: [120, 132, 101, 134, 90, 230, 210]
        },
        {
            name: '2的指数',
            type: 'line',
            data: [220, 182, 191, 234, 290, 330, 310]
        }
        ,
        {
            name: '2的指数',
            type: 'line',
            data: [320, 332, 301, 334, 390, 330, 320]
        }
    ]

期望结果 (Expected behaviour)

期望无论series的data怎么变化Y轴都是对数轴

可能哪里有问题 (What went wrong)

根据series的data值渲染Y轴刻度值得时候出错。

ECharts配置项 (ECharts option)

option = {
title: {
        text: '对数轴示例',
        left: 'center'
    },
    tooltip: {
        trigger: 'item',
        formatter: '{a} <br/>{b} : {c}'
    },
    legend: {
        left: 'left',
        data: ['2的指数', '3的指数']
    },
    xAxis: {
        type: 'category',
        name: 'x',
        splitLine: {show: false},
        data: ['一', '二', '三', '四', '五', '六', '七', '八', '九']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    yAxis: {
        type: 'log',
        name: 'y'
    },
    series: [
        {
            name: '3的指数',
            type: 'line',
            data: [120, 132, 101, 134, 90, 230, 210]
        },
        {
            name: '2的指数',
            type: 'line',
            data: [220, 182, 191, 234, 290, 330, 310]
        }
        ,
        {
            name: '2的指数',
            type: 'line',
            data: [320, 332, 301, 334, 390, 330, 320]
        }
    ]
}

其他信息 (Other comments)

image

@Ovilia
Copy link
Contributor

Ovilia commented May 7, 2016

如果你的问题的意思,不是“Y轴不是对数而是小数”,而是“如何使Y轴显示整数,那么设置 formatter 即可。

    yAxis: {
        type: 'log',
        name: 'y',
        axisLabel: {
            formatter: function(v) {
                return Math.floor(v);
            }
        }
    },

@pissang pissang added this to the 3.1.9 milestone May 9, 2016
@hejinenPrivate
Copy link
Author

好的 3Q

@hejinenPrivate
Copy link
Author

image
出现了个新的问题当Y轴为对数轴时,数据如果有一个为0那么Y轴显示不正常,如图。这个图就是官网实例里面的对数轴实例!只是把其中的一个数据改成了0!!

@pissang
Copy link
Contributor

pissang commented May 17, 2016

Math.log(0) 看下

@pissang pissang closed this as completed May 17, 2016
@pissang pissang reopened this May 17, 2016
@hejinenPrivate
Copy link
Author

image
是这样么?图像基本对了但是图像上少了一个点。显示不出0点那个值了!

@pissang
Copy link
Contributor

pissang commented May 17, 2016

我的意思是 0 的对数是没有意义的

@hejinenPrivate
Copy link
Author

对数轴的意思是Y轴的数值是成指数级增长的吧。和数值没有关系吧,现在数据中确实有数据是0 。比如我这个图表要显示最近30天的交易成交额,每天的成交额差距可能很大,有时候是千万,有时候是几百,有时候是几千,有时候为0。这种差距比较大,所以我们需要使用对数轴,在图表上显示出每天的成交额。。。。

@pissang pissang modified the milestones: 3.1.11, 3.1.10 Jun 1, 2016
@pissang pissang closed this as completed Oct 25, 2016
@liubei1
Copy link

liubei1 commented Dec 22, 2016

_ls4xxpnlfhj i0ln5e _ht
可以用这种方式解决,将数值中的0改为一个小数表示(这里数值种最小值为0.1,我用0.01表示0,并用formatter展现为0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants