Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.ordering not working for bar chart (ordinal x-axis) #772

Closed
lbk3918 opened this issue Nov 22, 2014 · 2 comments
Closed

.ordering not working for bar chart (ordinal x-axis) #772

lbk3918 opened this issue Nov 22, 2014 · 2 comments
Labels
Milestone

Comments

@lbk3918
Copy link

lbk3918 commented Nov 22, 2014

Ordering works fine for row charts, but doesn't work on my bar chart version of same data.
I can work around this

Here is bar chart code which doesn't do ordering - everything else works OK eg title;

sitecostchart.width(450)
.height(340)
.outerPadding(0)
.gap(1)
.margins({top: 0, right: 30, bottom: 50, left: 45})
.on("postRender", function( chart ){
adjustBarChartLabels(chart);
})
.x(d3.scale.ordinal())
.xUnits(dc.units.ordinal)
.brushOn(false)
.elasticY(true)
.ordering(function(d) {return -d.value })
.yAxisLabel("Cost £")
.title(function(d) {return d.key +
" £" + currFormat(d3.round(d.value)) +
" (" + d3.round((d.value / d3.sum(sitecostsum.all(),
function(d){ return d.value;}))*100,1) +"%)";})
.dimension(sitecost)
.group(sitecostsum);

Here is row chart code for same data where ordering works fine;

sitecostchart.width(350)
.height(400)
.margins({top: 10, right: 0, bottom: 20, left: 0})
.dimension(sitecost)
.group(sitecostsum)
.title(function(d) {return d.key +
" £" + currFormat(d3.round(d.value)) +
" (" + d3.round((d.value / d3.sum(sitecostsum.all(),
function(d){ return d.value;}))*100,1) +"%)";})
.transitionDuration(500)
.elasticX(true)
.ordering(function(d) {return -d.value })
.xAxis().ticks(5);

@gordonwoodhull
Copy link
Contributor

Confirmed - although coordinateGridMixin defines ordinalXDomain, this is immediately overridden by the stackMixin and never gets called for bar charts or line charts.

Looks like this might have been broken by 824b139. Will take more investigation to understand what was intended there.

@christianmalek
Copy link

@lbk3918 Could you please provide your workaround?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants