1
votes

I'd like to know if dc.js can render a bar chart without dimension, for example, a bar chart displaying the reduce result of ALL data.

enter image description here

When we want to render a bar chart we always do like this:

chart.width(400)
.height(200)
.dimension(...some Dimension here...)
.group(...some Group here...)
.valueAccessor(function (p) {
    return p.value.someValue;
})
.x(d3.time.scale().domain(["Global"]))
.y(d3.scale.linear().domain([0, 100]))
.yAxis().tickFormat(function (v) {
    return v + "%";
}); 
chart.render();

My question is what to put in the dimension and group in order to achieve my purpose? The documentation says that dimension() is mandatory.

Thanks very much!

1
Have you tried putting in a dummy dimension?Lars Kotthoff
Sorry, what is a dummy dimension?wceo
Just add an additional data attribute that is the same for everything and use that as dimension.Lars Kotthoff
This is a great answer! It works now! Thanks very much!wceo
Great, I'll add that as an answer for reference.Lars Kotthoff

1 Answers

2
votes

The easiest way to do this is probably to add an additional attribute to your data that has the same value for everything and use that as the dimension.