rowChart ordering is ignored when .data is used

13 views
Skip to first unread message

Lucas Viani

unread,
Oct 7, 2022, 8:33:57 AM10/7/22
to dc-js user group
Hello!

I am having a problem when trying to sort a rowChart.
Normally the .ordering call works perfectly, but in this specific case, I need to get rid of the bar with zero value.
I am removing the bars with zero value using the .data call, but when I do so, the .ordering call is ignored.

Is there a different way to do not display the bars with zero value and order the plot?

A simple example of what I am doing is the following:

        var dim = cf.dimension(function (d) { return d["variable"]; })
        var grp =  dim.group()
        var reducer = reductio().avg(function(d) { return d.value; })
        reducer( grp )

        chart = dc.rowChart("#prAvg-chart")
        chart
            .dimension( dim )
            .group( grp  )

            .ordering(function(d) { return -d.value.avg })
            .data(function(group) {
                return group.all().filter(function(d) { return d.value.avg > 0 })
            })

Lucas Viani

unread,
Oct 10, 2022, 3:01:51 AM10/10/22
to dc-js user group
Hi...

At the end I sorted the group prior to its assignation to the chart.
A similar solution is used in here

I still think that the .ordering should work independently of the .data call.

Cheers!

Gordon Woodhull

unread,
Oct 10, 2022, 11:00:48 AM10/10/22
to dc.js user group
Hi Lucas,

Yes, it is confusing, .data() is the way to customize data, but it is used internally to customize the data pipeline, e.g. for capping.

Some old discussion is here: https://github.com/dc-js/dc.js/issues/584

I think this is one of the things Deepak has improved in v5, you might give it a try if you're interested.

Cheers,
Gordon


-- 
You received this message because you are subscribed to the Google Groups "dc-js user group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dc-js-user-gro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dc-js-user-group/222546bc-bb10-4492-ac3c-64a0e3a058c5n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages