For Bar Chart and Stacked Chart, we can use .xAxisLabel("X Axis Label")
and .yAxisLabel("Y Axis Label")
functions to add labels for respective axis.
But,
Is there any way to add axis labels for Row Chart?
Asked
Active
Viewed 8,200 times
5

ndpu
- 22,225
- 6
- 54
- 69

Bhatu Pawar
- 53
- 1
- 4
1 Answers
17
Try something like this:
dc.renderAll();
function AddXAxis(chartToUpdate, displayText)
{
chartToUpdate.svg()
.append("text")
.attr("class", "x-axis-label")
.attr("text-anchor", "middle")
.attr("x", chartToUpdate.width()/2)
.attr("y", chartToUpdate.height()-3.5)
.text(displayText);
}
AddXAxis(chart1, "This is the x-axis!");
Here is a jsfiddle example: http://jsfiddle.net/djmartin_umich/x5qb9/
I hope this helps! -DJ

DJ Martin
- 2,579
- 20
- 24
-
Do you know a solution without jQuery ? – Tomasz Waszczyk Mar 11 '16 at 13:56
-
tks.what do you have to change to add a label to the y-axis? – HattrickNZ Sep 22 '16 at 03:39