Forum Discussion

FICO's avatar
FICO
Community Manager
6 years ago

How to sort vdl-chart sort x-axis by entity values?

VDL v7 added the nice set-sorter, but seems to have made the default sorting a bit inconsistent. VDL-table sorts by entity values by default, but VDL-chart seems to do a random sort (at first thought it was sorting the labels, but that isn't the case). This is a problem for me, and I don't see a way to even access the entity values in a set-sorter. Any advice appreciated!

For example, in Mosel I have these entities:

[email protected] Times_Label
[email protected] Time period
Times: range
Times_Label: array(Times) of string
Profit: array(Times) of real

and in VDL I have this view:

<vdl-table>
  <vdl-table-column entity="Profit"/>
</vdl-table>
 
<vdl-chart>
  <vdl-chart-series entity="Profit"/>
  <vdl-chart-axis axis="x" type="category"/>
</vdl-chart>

Then I get these two different time period sortings:

Capture1

Capture2

where you can see that the x-axis on the chart (bottom image) has the time periods out of order. I can't tell what is the default sorting of vdl-chart.

5 Replies

  • FICO's avatar
    FICO
    Community Manager

    Adding a set-sorter fixed the sorting of the vdl-chart x-axis without effecting the sorting of the vdl-table:

    <vdl-set-sorter comparator="string" set="Times"/>

    It's unclear to me why the set-sorter works with the comparator "string" and not "numeric".

  • FICO's avatar
    FICO
    Community Manager

    Alex_Chart_Sort

    Hi Alex,

    we tried your example with some dummy data here. It seems to be sorting by underlying values on the x-axis OK.

    Alex_Chart_Sort_data

    Is there something else at play?

    Best regards,

    Joc O'Connor

  • FICO's avatar
    FICO
    Community Manager

    Hmm, it's a mystery to me. Thanks for the quick analysis and reply! My approach works well enough for now.

  • FICO's avatar
    FICO
    Community Manager

    Could be related to that, but the table is sorted ascending by the set indexes (default sorting for vdl-table) and it's the vdl-chart that has the incorrect sorting. I don't think there's button for the user to change the vdl-chart x-axis sorting.