3

I have successfully created a bar chart using Data Plotly within QGIS 3.14.16. The x axis consists of 17 place names (NAME) and the Y axis shows the value (VALUE IN £P) of one particular lease at each location, ranging from £0 to £46. This is an historical chart. However I would like the plots to be ordered by value so that the lowest value is on the left and the rest graduated to the highest value on the far right of the plot.

Is this possible? Can any kind person provide me with an expression to achieve this please?

Please see the chart shown below.1

1
  • It is done with a JavaScript function inside the chart. You would have to go through the entire array and with the function to reorder, so I do it and the graphs are ordered in the way I want, I even place in the same function not only that I order them from smallest to largest but I can make them order them from the way I like it the most. ----- Se hace con una función JavaScript dentro del gráfico. Tendrías que recorrer todo el array y con la función hacer el reorder, así lo hago y salen los gráficos ordenados de la manera que deseo incluso coloco en la misma función no solamente que los ord Jan 17, 2021 at 2:10

2 Answers 2

3

By default, Plotly represents your data in the order of insertion. The first inserted element has the id 0. Here is a tip to get the expected result.

enter image description here

You can also retrieve this value by creating a new field and assigning it the value $id.

enter image description here

Here is the result obtained.

enter image description here

A trick is to directly modify the file containing the attribute table (example .dbf file for the shapefile). You cannot edit this file if it is opened in QGIS. Sort the VALUE field in descending order if you want to display the data in descending order and then save. This will change the element IDs.

enter image description here

Add the layer to your project and here is the result.

enter image description here

1

You can create a virtual layer on your data source and order it in the desired display order.

enter image description here

2
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center. Sep 13 at 10:07
  • Layer > Create Layer > New Virtual Layer. Add in the layer you want to the embedded layers. Use a query like this select* from yourlayer order by yourcolumn desc
    – Sethinacan
    Sep 20 at 12:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.