Skip to content

Commit

Permalink
histogram - supported one dimensional array input data, updated demo
Browse files Browse the repository at this point in the history
  • Loading branch information
mwasiluk committed Aug 30, 2016
1 parent a9e4145 commit 01c15a0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 22 deletions.
8 changes: 2 additions & 6 deletions dist/odc-d3.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion 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.

26 changes: 19 additions & 7 deletions examples/histogram/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ var confFlowers = {
key: 'petal length',
label: 'petal length'
},
groups:{
key: 'species',
label: "species"
}
// groups:{
// key: 'species',
// label: "species"
// }

};
// conf = new ODCD3.ScatterPlotConfig();
Expand All @@ -27,11 +27,23 @@ var dataArray = [
[5,4, 2]

];
var plot;
var plot, plot2;
var conf = confFlowers;




var values = d3.range(1000).map(d3.random.bates(20));
plot = new ODCD3.Histogram("#plot", values, {
x:{
ticks: 14
}
});

d3.csv("../data/flowers.csv", function(error, data) {
console.log(data);
plot = new ODCD3.Histogram("#plot", data, conf);
plot2 = new ODCD3.Histogram("#plot2", data, conf);

});


});
4 changes: 3 additions & 1 deletion examples/histogram/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
<body>
<h1>Histogram demo</h1>

<div id="plot" style=" max-width: 600px;"></div>
<div id="plot" style=" max-width: 600px;margin-bottom: 40px"></div>
<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>
Expand Down
8 changes: 2 additions & 6 deletions src/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export class HistogramConfig extends ChartConfig{
x={// X axis config
label: '', // axis label
key: 0,
value: (d, key) => d[key], // x value accessor
value: (d, key) => Utils.isNumber(d) ? d : d[key], // x value accessor
scale: "linear",
ticks: undefined
ticks: undefined,
};
y={// Y axis config
label: '', // axis label,
Expand Down Expand Up @@ -116,10 +116,6 @@ export class Histogram extends Chart{

y.axis = d3.svg.axis().scale(y.scale).orient(conf.orient);

if(this.config.guides){
y.axis.tickSize(-plot.width);
}

var data = this.data;
plot.y.scale.domain([0, d3.max(plot.histogramBins, d=>d.y)]);
};
Expand Down

0 comments on commit 01c15a0

Please sign in to comment.