min/max on yAxis for bar charts, makes the bars go outside limits
See original GitHub issueOne-line summary [问题简述]
Setting custom min/max values on the yAxis for bar charts, makes the bars go below the lowest limit of x axis and above the highest limit of y axis.
Version & Environment [版本及环境]
- ECharts version [ECharts 版本]: 4.1.0
- Browser version [浏览器类型和版本]: 68.0.3440.84
- OS Version [操作系统类型和版本]: macOS High Sierra 10.13.3
Expected behaviour [期望结果]
Without min/max on bar chart I get,
When I set min/max on bar chart I get,
I do not face this issue if I change the chart type to line,
Line without min/max:
Line with min/max:
What can I do to make min/max for bar behave like line ? Is there some way I can prevent the bars from going outside limits ?
ECharts option [ECharts配置项]
option = {
xAxis: {
type: 'category',
data: ['Foo', 'Bar', 'Baz']
},
yAxis: {
type: 'value',
min: 200,
max: 250
},
series: [{
data: [100, 200, 300],
type: 'line' // 'bar'
}]
};
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:19 (4 by maintainers)
Top Results From Across the Web
setting custom min/max value of y-axis on bar charts in echarts ...
My problem is i want to give the minimum on y-axis as 0 but maximum as either the addition of maximum of two...
Read more >Automatically setting Y-axis limits for a bar graph using ...
To set Y-axis limit, we can use ylim() method and put maximum and minimum limit values. Steps. Set the figure size and adjust...
Read more >Set Minimum and Maximum Values on Value Axis ... - Indezine
Now you can see that the maximum and minimum values on the value axis have changed to new values. If you compare the...
Read more >yAxis.max | highcharts API Reference
In case of an inverted column chart or a bar chart the label is placed to the right of positive bars and to...
Read more >Bar Charts - NCL Graphics
Bar charts (in this context) are simply XY plots that are drawn with bars for each X,Y point. To get bars instead of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You example doesn’t include the layout clipping function??? You need to add the function and register it using the global echarts function. If you try the code below in your jsfiddle example it will clip the bars 😉
@suremicro No need to go the custom chart route. I’ve solved this using a similar solution to yours but instead of creating a custom chart, I update each bar’s layout properties. You can update each bar’s layout by registering a layout function before initializing your chart.
Example:
I use this technique of registering layout functions for my charts quite often to do things like dynamically showing or hiding series labels depending if they fit.