-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Dynamic yaxis max value #211
Comments
Try this var max = 0;
var data = [4, 3, 5, 2];
data.map(d => {
max = Math.max(max, d)
})
options: {
yaxis: {
max: max + 1
}
} |
@junedchhipa I'v managed to add my +1 to the maximum value after my axios request. But now I'm struggling to apply it to my max yaxis value. I've tried with the computed data but without success.. After my axios request, I do this:
This sets the "max" value to 6 in my case. In my computed properties, I try this:
I've based my approach on the other computed properties above. |
When you update the options, update the whole object instead of updating nested property.
|
@junedchhipa But I got a whole other stuffs in my options object.. I've tried to put all of it in the computed part but then I got this "object expected but array given" error.. |
The spread operator will help to update nested property. this.chartOptions = {...this.chartOptions, ...{
yaxis: {
max: max
}
}}; |
@junedchhipa But where do I put this? |
You may put in |
@junedchhipa I cannot make it work. Nothing that I do changes the value.. Is it not easier to have something like a formatter? For the dataLabels, there's something like this:
|
I will test if changing yaxis max value works or not. This was an issue faced by a couple of users, so let me look into it. |
Here is a working example of changing <div class="example">
<apexcharts
width="500"
height="350"
type="bar"
:options="chartOptions"
:series="series"
></apexcharts>
</div> export default {
name: "Chart",
data: function() {
return {
series: [
{
data: [3, 5, 10, 15, 20, 30, 45]
}
]
};
},
computed: {
chartOptions: function() {
return {
yaxis: {
max: Math.max(...this.series[0].data) + 10
}
};
}
}
}; |
@junedchhipa The problem with my code is that I have other properties for the "options" value. I've updated the code here to fetch exactly my situation: https://codesandbox.io/s/my53x17n9 As you can see, I get this error: The computed property "options" is already defined in data. |
Updated your example - https://codesandbox.io/s/2p2x0zwpqn It is not valid to have the same prop in |
Yes It worked! Gosh that was long. Thank you so much! |
On button click..I want to get xaxis node. I am using this but not able to get xaxis value. |
Hi!
In my chart, I have some data that represents sales during a given time. I put the labels on top of each bar. But, for the max value, it is cutted off and doesn't show the label.
Here, my max value is 5 and the label for the corresponding bar is outside. Is it possible to add dynamically +1 to the max value?
I have tried with several tests but none have worked out yet.
Thanks for your help!
The text was updated successfully, but these errors were encountered: