apache / apache/echarts

Duplicate labels on a time(year format) xAxis

Open
#9,896 7 comments 2 reactions 1 assignee Claimed by @100pah View on GitHub
enhancement priority: high
Dominant language
TypeScript
Stars
67.3k
Forks
19.8k
Avg merge
11d 14h
Merged PRs (30d)
8

Description

## General Questions

## Issue Type

- [ ] I have a question to ask about *how to use ECharts to ...*;我想提问如何使用 ECharts 实现某功能
- [x] I have a bug to report;我想要报 bug
- [ ] I have a feature to request, e.g.: *I'd like a new feature that ...*;我需要一个新功能
- [ ] I have a feature to enhance, e.g.: *The current feature should be improved in the way that ...*;我希望改进某个功能
- [ ] There's something wrong with the documents;文档有些问题
- [ ] Others, or I'm not sure which issue types to choose here;其他,或我不知道应该选什么类型

## Issue Details

I want to use a year format on a timeAxis, but formatting the axisLabel ends up with duplicate labels.

### Expected Behavior

![duplicate_labels_fixed](https://user-images.githubusercontent.com/17814451/52337171-9c7fad80-2a0f-11e9-826c-78256c92d6e6.png)

There shouldn't be any duplicate labels if it's a time axis.

### Current Behavior

![duplicate_labels](https://user-images.githubusercontent.com/17814451/52337003-17949400-2a0f-11e9-81de-1e6503666fd6.png)

The points seem to be plotted and formatted afterwards. This means that points in the same year, are all formatted to the same label.

### Online Example

Fiddle link: https://jsfiddle.net/5jyu4t6w/5/

```
option = {
"xAxis" : [
{
"type" : "time",
"axisLabel" : {
formatter : function(x) {
return echarts.format.formatTime('yyyy', x);
}
},
"splitLine" : {
"show" : false
},
"max" : "dataMax",
"scale" : true,
"offset" : 0
}
],
"yAxis" : [
{
"type" : "value",
"axisLabel" : {
formatter : function(x) {
return (x*100) + "%";
}
},
"splitLine" : {
"lineStyle" : {
"type" : "dashed"
}
},
"offset" : 0
}
],
"series" : [
{
"name" : "Example line",
"type" : "line",
"data" : [
[
1577829599999,
0.01
],
[
1609451999999,
0.02
],
[
1640987999999,
0.3
]
]
},
]
}
```

## Topics

## Anything Else We Need to Know

Setting the axis type to 'category' is something we considered but it's not correct

## Environment

- ECharts version;ECharts 版本: Latest version (4.2)

- [ ] It happens only on certain browsers or operating systems. 对于特定浏览器或操作系统才会出现的问题,请提供相应环境信息:{BROWSER_VERSION_OR_OS_INFORMATION_HERE}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.