2👍
✅
Try this.
var positon ={
options: {
sort:"desc"
}
}
onSortClick() {
positon.options.sort = positon.options.sort === "desc" ? "asc": "desc"
return positon.options.sort;
};
In your plunker do these changes.
Add a button.
<button id="sort-btn">Sort</button>
Add an event listner
document.getElementById("sort-btn").addEventListener("click", function() {
config.options.sort = config.options.sort === "desc" ? "asc" : "desc";
var ctx = document.getElementById("chart-area").getContext("2d");
window.myDoughnut = new Chart(ctx, config);
console.log(config.options.sort);
});
0👍
It’s very simple you just have to create an event listener.
<input type="button" id="myCheck" onclick="reverse()">
<script>
function reverse() {
config.options.sort = "asc";
}
</script>
Source:stackexchange.com