I'm trying to implement bar totals at with bar charts in a very similar manner as you would with row charts. For row charts, the code would be
Chart
.width(500)
.height(500)
.dimension(chartDim)
.group(chartGroup)
.title(function(d) {
return d3.format(",f")(d.value); // or your custom value accessor
})
.renderTitleLabel(true)
.titleLabelOffsetX(50)
.xAxis().tickFormat(function(v) {
return "";
});
This will return a chart with the values of it at the end of the row charts with the elasticX
functionality. However, when it comes to bar chart, you would have to implement a renderlet
solution like this and this where you have to manually draw the bar totals.
The issue I have with this approach is that 1) the y domain isn't elastic, so if there are wide variations in your selections, the bar totals may not show, and 2) you have to manually determine the range for the y axis.
Is there a more elegant way to create bar totals in a more elegant way without relying on the renderlet
solution, something preferably similar to the row chart solution?