Skip to content

Commit

Permalink
add more xample implementations of the waffle-vis
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck committed May 22, 2017
1 parent 00fa1cb commit 5d04fd6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core_plugins/waffle_chart2/public/vis_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ class VisController {
}

render(vis, visData) {

window._vis = vis;

return new Promise((resolve) => {

this._clear();


try {
const label = vis.aggs[0].makeLabel() + ': '+ vis.aggs[1].makeLabel();
const data = convertResponse(visData);
this._createWaffleVis(data);
this._createWaffleVis(data, label);
} catch (e) {
//handle error
}
Expand All @@ -31,7 +37,7 @@ class VisController {
}


_createWaffleVis(data) {
_createWaffleVis(data, label) {
//copy pasted from http://bl.ocks.org/XavierGimenez/8070956
const widthSquares = 20;
const heightSquares = 5;
Expand Down Expand Up @@ -96,7 +102,7 @@ class VisController {
})
.append('title')
.text(function (d) {
return 'Age range: ' + data[d.groupIndex].key + ' | ' + d.value + ' , ' + d.units + '%';
return label + ' ' + data[d.groupIndex].key + ' | ' + d.value + ' , ' + d.units + '%';
});

//add legend with categorical data
Expand Down

0 comments on commit 5d04fd6

Please sign in to comment.