logo
Search
showing results for - "how to sort by data in chart js"
Steven
28 Jun 2018
1  const arrayOfObj = chartLabels.map(function (d, i) {
2    return {
3      label: d,
4      data: chartValues[i] || 0,
5    }
6  })
7
8  const sortedArrayOfObj = arrayOfObj.sort(function (a, b) {
9    return b.data - a.data
10  })
11
12  let newArrayLabel = []
13  let newArrayData = []
14  sortedArrayOfObj.forEach(function (d) {
15    newArrayLabel.push(d.label)
16    newArrayData.push(d.data)
17  })
source
similar questions
boble sorting javascriptjs sort ascendignload sort on string javascriptsort date string in javascriptsort js array by datesort by timestamp javascriptsort by price in javascriptsort by ascending javascriptjavascript sort array in ascending orderwhy sort is not working in javascriptjavascript sort chars in stringsort by date jsjavascript check string sort ascendingsortable js handlehow to sort string aray in tsjs sort by title 28string value 29sort array by a value jssort date array javascript
queries leading to this page
chart js order datachart js sort datasetchart js sortable chartchart js order of datachart js sort based on timehow to sort by data in chart jschart js sort datasort data for chart in jschart js sort options examplechart js order by valuechart js sorthow to sort by data in chart js
privacy policyterms of useinstagram
Crafted with  ♥  for everyone

sign in to continue
your answer for
you will get a confirmation link on this - you will have to click that for successful submission of your answer. we require this to keep the website free of spam, bots and unhelpful content
please ensure to add code which is syntactically corrent and executes properly
sign in to continue
ask question on maxinterview
you will get a confirmation link on this - you will have to click that for successful submission of your question. we require this to keep the website free of spam, bots and unhelpful content
please be clear, to the point and respectful
sign in to continue