Skip to content

Commit

Permalink
histogram - updated demo, layer.exit
Browse files Browse the repository at this point in the history
  • Loading branch information
mwasiluk committed Aug 31, 2016
1 parent 0cef3d6 commit 33329c2
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 31 deletions.
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"simple-statistics": "^2.0.0",
"d3-legend": "^1.10.0",
"moment": "^2.14.1",
"lodash": "^4.15.0"
"lodash": "^4.15.0",
"jquery": "^3.1.0"
}
}
17 changes: 8 additions & 9 deletions dist/odc-d3.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/odc-d3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/odc-d3.min.js.map

Large diffs are not rendered by default.

27 changes: 19 additions & 8 deletions examples/histogram/demo.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
var flowerGroups = {
key: 'species',
label: "Species"
};

var confFlowers = {
x:{
key: 'petal length',
label: 'petal length'
key: 'sepal width',
label: 'sepal width'
},
groups:{
key: 'species',
label: "Species"
}
// groups: false

groups:flowerGroups
};

// conf = new ODCD3.ScatterPlotConfig();
// conf.guides = true;

Expand Down Expand Up @@ -49,5 +50,15 @@ d3.csv("../data/flowers.csv", function(error, data) {
plot2 = new ODCD3.Histogram("#plot2", data, conf);

});
$("#plot2-stacked").change(function(){

confFlowers.groups = this.checked ? flowerGroups : false;

plot2.setConfig(confFlowers).init();
});

$("#plot2-x-key").change(function(){

confFlowers.x.label = confFlowers.x.key = $(this).val();
plot2.setConfig(confFlowers).init();
});
13 changes: 13 additions & 0 deletions examples/histogram/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@
<h1>Histogram demo</h1>

<div id="plot" style=" max-width: 600px;margin-bottom: 40px"></div>
<p>
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="plot2-stacked">
<input type="checkbox" id="plot2-stacked" class="mdl-checkbox__input" checked>
<span class="mdl-checkbox__label">Stacked</span>
</label>
<select id="plot2-x-key">
<option value="sepal width">sepal width</option>
<option value="sepal length">sepal length</option>
<option value="petal width">petal width</option>
<option value="petal length">petal length</option>
</select>
</p>
<div id="plot2" style=" max-width: 600px;margin-bottom: 40px"></div>


<script src="../../bower_components/d3/d3.min.js" charset="utf-8"></script>
<script src="../../dist/odc-d3.js" charset="utf-8"></script>
<script src="../../bower_components/jquery/dist/jquery.min.js" charset="utf-8"></script>
<script src="demo.js"></script>
</body>
</html>
13 changes: 6 additions & 7 deletions src/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,12 @@ export class Chart {

initPlot() {
var margin = this.config.margin;
this.plot={
margin:{
top: margin.top,
bottom: margin.bottom,
left: margin.left,
right: margin.right
}
this.plot = this.plot || {};
this.plot.margin = {
top: margin.top,
bottom: margin.bottom,
left: margin.left,
right: margin.right
};
}

Expand Down
3 changes: 1 addition & 2 deletions src/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export class Histogram extends Chart{
color: null//color scale mapping function
};


this.plot.showLegend = conf.showLegend;
if(this.plot.showLegend){
this.plot.margin.right = conf.margin.right + conf.legend.width+conf.legend.margin*2;
Expand Down Expand Up @@ -267,7 +266,7 @@ export class Histogram extends Chart{
.style("opacity", 0);
});
}

layer.exit().remove();
bar.exit().remove();
}

Expand Down

0 comments on commit 33329c2

Please sign in to comment.