this version adds a legend!
to enable the legend symbol to interact with the areas, when you call RadarChart()
, specify the field radarChart.js
should use to assign an areaName
to each area.
you can also specify the legend position as a parameter, where x
and y
are pixel coordinates offset from an origin at the top left of the parent svg
.
var legendPosition = {x: 25, y: 25}
var radarChartOptions {
areaName: "device",
legendPosition: legendPosition
// ...
};
to get the interaction to work, we add a data-driven class to each area that we can later select in the cellover()
function that is called when you mouse over the legend symbol.
blobWrapper
.append("path")
.attr("class", function(d) {
return "radarArea" + " " + d[0][areaName].replace(/\s+/g, '') //Remove spaces from the areaName string to make one valid class name
})
// ...
the legend is created with the delightful d3-legend component from susielu
an iteration on the bl.ock radar chart with smallest area on top by micahstubbs
a further iteration on the bl.ock Radar Chart Redesign created by nbremer, which is described nicely in this blog post
forked from micahstubbs's block: radar chart with an interactive legend
forked from anonymous's block: radar chart with an interactive legend
forked from wholegrainmultigrain's block: radar chart with an interactive legend
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js
https://cdnjs.cloudflare.com/ajax/libs/d3-legend/1.3.0/d3-legend.js