Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredkam committed May 15, 2015
2 parents 3d369e6 + 966e6d4 commit d012bd8
Show file tree
Hide file tree
Showing 57 changed files with 1,175 additions and 3,045 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ coverage/
app.js
.tmp
.build
lib/
npm-debug.log
testData/
testData.json
12 changes: 10 additions & 2 deletions addons/Events.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,22 @@ module.exports = Class.extend({
// value: data[column]
// }
// };

//
var column = ((target.dataset || '').c || target.getAttribute('data-c'));
var point = data[column] || 0;
var tickSize = scale.tickSize;
var startTick = scale.startTick;
var minRadius = scale.minRadius || 0;
var radius = (scale.maxRadius - minRadius) * point.data / scale.max;
var cx;
radius = radius ? radius + minRadius : 0;
if (scale.autoFit == false) {
var i = target.getAttribute('data-c');
cx = (i * tickSize) + scale.paddingLeft + scale.innerPaddingLeft;
} else {
cx = ((point.date.getTime() - startTick) * tickSize) + scale.paddingLeft + scale.innerPaddingLeft;
}

return {
scale: scale,
_segmentXRef: column,
Expand All @@ -195,7 +203,7 @@ module.exports = Class.extend({
eY : eY,
eX : eX,
cY : scale.height / 2,
cX : ((point.date.getTime() - startTick) * tickSize) + scale.paddingLeft + scale.innerPaddingLeft,
cx : cx,
r : radius
}
}
Expand Down
57 changes: 50 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var Label = require('./addons/Label');

// TODO:: fix edge case of 1 data Point
var dataPoints = 30;
var nOfGraphs = 14;
var nOfGraphs = 17;
var kind = 11;
var oddKinds = 4;
var amount = nOfGraphs;
Expand Down Expand Up @@ -182,6 +182,52 @@ while (amount--) {
paddingBottom: 0,
}) + "</div>";

nodes += "</div><div class='graph'>" + bubblePointComplex().attr({
// Width & height controls the svg view box
width: 300,
height: 100,

/* Optional parameters */
/* Options for the straight line */
axis: {
strokeColor: '#000', // sets stroke color,
strokeWidth: 2
},
autoFit: false,
minRadius: 5,
maxRadius: 15, // Overrides default & sets a cap for a max radius for the bubble
strokeColor: '#000', // Set default stroke color
strokeWidth: 2, // Set default stroke width
fill: '#333', // Sets default fill color
// startDate: 1418885572796,
// endDate: 1439253572796,
// points: [
// {
// date: new Date(2015,2,1),
// data: 300,
// fill : '#000'
// // meta: Object
// },
// {
// date: new Date(2015, 4, 30),
// data: 150,
// fill : '#000'
// // meta: Object
// },
// {
// date: new Date(2015, 9, 30),
// data: 200,
// fill : '#000'
// // meta: Object
// }],
points: samplePoints,

/* Padding options for the chart */
paddingLeft: 0,
paddingRight: 0,
paddingTop: 0,
paddingBottom: 0,
}) + "</div>";

var sparkInstance = spark('.graph');

Expand Down Expand Up @@ -555,17 +601,14 @@ console.log('Took ' + diff + 'ms to generate ' + (nOfGraphs * kind + oddKinds) +
nodes = '<div>' + 'Took ' + diff + 'ms to generate ' + (nOfGraphs * kind + oddKinds) + ' graphs with '+ dataPoints + ' different data points avg of ' + (diff/((nOfGraphs*kind)+oddKinds)) + 'ms' + '</div>' + nodes;

// test optimization => round all numbers to 1 decimal place
nodes = nodes.replace(/([0-9]+\.[0-9]+)/g, function (match, p1) {
return Math.round10(p1, -1);
});
//nodes = nodes.replace(/([0-9]+\.[0-9]+)/g, function (match, p1) {
//return Math.round10(p1, -1);
//});

var str = '<html><head>'+
"<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,600' rel='stylesheet' type='text/css'>"+
'</head><body>' + nodes + '</body><style>.graph {display:inline-block;}</style></html>';

//var body = document.getElementsByTagName('body')[0];
//body.innerHTML = nodes;


var proxy = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
Expand Down
1 change: 1 addition & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
],
"license": "MIT",
"ignore": [
"src",
"**/.*",
"node_modules",
"bower_components",
Expand Down
4 changes: 2 additions & 2 deletions demo/bundle.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions demo/example/timeSeries/react-bubble-hover-tooltip/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ var bubbleSet = dataSet5

var bubblePoint =[
{
date: new Date(2015,2,1),
// date: new Date(2015,2,1),
data: 300,
fill : '#000',
meta: {}
// meta: Object
},
{
date: new Date(2015, 4, 30),
//date: new Date(2015, 4, 30),
data: 150,
fill : '#000',
meta: {}
// meta: Object
},
{
date: new Date(2015, 9, 30),
//date: new Date(2015, 9, 30),
data: 200,
fill : '#000',
meta: {}
Expand All @@ -57,4 +57,4 @@ React.render(
<BubblePoint set={bubblePoint} />
<BubbleScatter set={bubbleSet}/>
</div>,
document.getElementsByTagName('body')[0]);
document.getElementsByTagName('body')[0]);
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var ToolTip = React.createClass({
* data : {
x : Number (eg. time),
y : Number (sample size),
meta : {}
meta : {}
},
* eY : mouse event y,
* eX : mouse event x,
Expand Down Expand Up @@ -91,6 +91,7 @@ module.exports = React.createClass({
width: 1200,
height: 100,
points: self.props.set,
autoFit: false,
/* Optional parameters */
/* Options for the straight line */
axis: {
Expand All @@ -117,11 +118,11 @@ module.exports = React.createClass({

var self = this;
return (
<Bubble
<Bubble
chart={chart}
events={self.events}
toolTip={toolTip}
legend={legend} />
);
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
module: {
loaders: [
{test: /\.jsx$/, loaders: ['react-hot', 'jsx-loader?harmony']},
{test: /\.es6\.js$/, loader: 'es6-loader'},
{test: /\.es6\.js$/, loader: 'babel-loader'},

// compile and include less files
{test: /\.less$/, loader: 'style-loader!css-loader!autoprefixer-loader!less-loader'},
Expand All @@ -29,4 +29,4 @@ module.exports = {
resolve : {
extensions: ['', '.js', '.es6.js', '.jsx']
}
};
};
Loading

0 comments on commit d012bd8

Please sign in to comment.