Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top