You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "soniyaprasad77 (via GitHub)" <gi...@apache.org> on 2023/11/28 17:55:49 UTC
Re: [I] [Bug] BarChart does not respect yAxis.min when all data is below min (and max is undefined) [echarts]
soniyaprasad77 commented on issue #19187:
URL: https://github.com/apache/echarts/issues/19187#issuecomment-1830391499
@tmtron
Here's a revised code snippet implementing the dynamic adjustment of yAxis.max based on whether all data points are below zero:
const data = [-1, -2, -3]; // Example data
const threshold = 220;
// Check if all data points are below zero
const allBelowZero = data.every(value => value < 0);
// Dynamically set yAxis.max based on the condition
const maxY = allBelowZero ? threshold + 10 : null;
const option = {
xAxis: {
type: 'category',
data: ['A', 'B', 'C'] // Example categories
},
yAxis: {
type: 'value',
min: threshold,
max: maxY // Set to threshold + 10 if all data points are below zero
},
series: [
{
data: data,
type: 'bar'
}
]
};
This adjustment allows for a more dynamic setting of the yAxis.max based on the data provided, ensuring the chart accommodates the range while avoiding hard-coded values. It keeps the configuration adaptable and avoids unnecessary complexity in the input dialogs or source code.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org