I create a Flexmonster with JSON data, like:
var pivot = new Flexmonster({
container: "pivot",
report: {
dataSource: {
dataSourceType: "json",
filename: "/api/v1/stats/"
}
},
reportcomplete: function() {
pivot.off("reportcomplete");
createChart();
}
})
And then I render a Highcharts Column-Chart like:
function createChart() {
var render = function(data) {
Highcharts.chart('pivot_chart', data);
}
pivot.highcharts.getData(
{
type: "column",
"slice": {
"rows": [
{
"uniqueName": "total_salary",
}
],
"columns": [
{
"uniqueName": "[Measures]"
},
{
"uniqueName": "status"
}
],
"measures": [
{
"uniqueName": "number_of_persons",
"aggregation": "sum"
}
]
}
},
render, // callbackHandler
render // updateHandler
);
}
My total_salary values look like: "< 30'000", "30'000 - 40'000", "60'000 - 70'000" but they are not ordered like this in the chart. I tried to set the sortOrder like:
"rows": [
{
"uniqueName": "total_salary",
"sortOrder": ["< 30'000", "30'000 - 40'000", "60'000 - 70'000"]
}
],
But it's not working. Can somebody explain me how to do this? Thanks a lot!
Hi Silvan,
Thank you for posting your question!
In order for the column sorting to work as expected, we would suggest defining the sorting order in the slice of the pivot table object instead of the `pivot.highcharts.getData` method. This way the order of fields displayed by Highcharts instance will be derived from that of the pivot table instance.
We've prepared a quick JSFiddle example to demonstrate this functionality: https://jsfiddle.net/flexmonster/gxon7rev/
Please let us know if the described approach works for you.
Best regards,
Mykhailo