Open ndarville opened 11 years ago
value,A,B,C,F,I,K,O,V,Ø
%,29,9,4,6,4,0,13,22,9
$,29,9,4,6,4,0,13,22,9
#,29,9,4,6,4,0,13,22,9
To do:
Similar to bill votes chart:
Dissimilar:
color()
code; seems superfluousdataset.length
times<text>
Labelling Text Labels
Symbols
var data
How to render the text labels?
Where to place the legend: below or to the side?
This is the current code:
// Display text labels
var keys = Object.keys(jsonData);
g.selectAll(".name")
.data(domain)
.enter().append("text")
.attr("class", "name")
.attr({
"text-anchor": function(d) {
return (x(d) > (x.range()[0] + x.range()[1])/2) ? "end" : "start";
}, // Revise
"x": x,
"y": 0 // Revise
})
.text(function(d, i) { // fetch string
return keys[i];
});
And this is the data:
var jsonData = {
"Ryan Budget": {
"percentage": 0,
"money": 0
},
"Senate Democrats": {
"percentage": 2.3,
"money": 975000000000
},
"Progressive Caucus": {
"percentage": 14.1,
"money": 3900000000000
}
};
And this is what it ends up looking like:
It’s going to be a royal pain to handle this programmatically—not to imply that it won’t be a pain to handle manually either.
So perhaps the primary visualization should be with symbols and a legend, while I wait for an idea for how to go about the text labels, until someone hands a solution down to me a dream.
Need to find out a way to define vertical positioning for the value and legend text:
These are the two values:
var xPos = (x.range()[0] + x.range()[1])/2 - 25; // <-
///
g.selectAll(".name")
.data(domain)
.enter().append("text")
.attr("class", "name")
.attr({
"text-anchor": function(d) {
return (x(d) > (x.range()[0] + x.range()[1])/2) ? "end" : "start";
}, // Revise
"x": x,
"y": 0 // Revise
})
.text(function(d, i) { // fetch string
return keys[i];
});
Better to group the chart into three <g>
elements:
Perhaps a good way of going about many or adjacent values is to either include an option that only displays values at the minimum, average, and maximum.
http://upwithsteve.tumblr.com/post/45700087207/how-the-center-gets-defined-in-the-budget-debate