Skip to content

Instantly share code, notes, and snippets.

@nicohaemhouts

nicohaemhouts/_.md

Last active Aug 29, 2015
Embed
What would you like to do?
CDS EventsPerSecond 2
{"description":"CDS EventsPerSecond 2","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/GtIjgye.png"}
[
{
"__v": 0,
"_id": "559e6c0bf8e842c65bf7e548",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 2000,
"eventsPerSecond": 0
},
"metrics": {
"numberOfEventsToMatch": 0,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T12:41:47.525Z"
},
{
"__v": 0,
"_id": "559e6adff8e842c65bf7e546",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 2000,
"eventsPerSecond": 1778
},
"metrics": {
"numberOfEventsToMatch": 0,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T12:36:47.686Z"
},
{
"__v": 0,
"_id": "559e6866bf74e5415b2c6b7d",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 1000,
"eventsPerSecond": 1173
},
"metrics": {
"numberOfEventsToMatch": 41481,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T12:26:14.723Z"
},
{
"__v": 0,
"_id": "559e673abf74e5415b2c6b7b",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 4000,
"eventsPerSecond": 0
},
"metrics": {
"numberOfEventsToMatch": 0,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T12:21:14.089Z"
},
{
"__v": 0,
"_id": "559e660ebf74e5415b2c6b79",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 4000,
"eventsPerSecond": 1468
},
"metrics": {
"numberOfEventsToMatch": 0,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T12:16:14.299Z"
},
{
"__v": 0,
"_id": "559e64e2bf74e5415b2c6b77",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 1000,
"eventsPerSecond": 0
},
"metrics": {
"numberOfEventsToMatch": 0,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T12:11:14.135Z"
},
{
"__v": 0,
"_id": "559e6375afb4770d5b83a63e",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 2000,
"eventsPerSecond": 889
},
"metrics": {
"numberOfEventsToMatch": 41885,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T12:05:09.444Z"
},
{
"__v": 0,
"_id": "559e6249afb4770d5b83a63c",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 1000,
"eventsPerSecond": 1098
},
"metrics": {
"numberOfEventsToMatch": 0,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T12:00:09.961Z"
},
{
"__v": 0,
"_id": "559e6120afb4770d5b83a63a",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 2500,
"eventsPerSecond": 0
},
"metrics": {
"numberOfEventsToMatch": 116550,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T11:55:12.236Z"
},
{
"__v": 0,
"_id": "559e5ff1afb4770d5b83a638",
"gauges": {
"itemMatchService": {
"dbOperationsPerSecond": 2500,
"eventsPerSecond": 0
},
"metrics": {
"numberOfEventsToMatch": 0,
"totalEmsEvtEvents": 425769273,
"totalEmsEvtItems": 301123953,
"totalInterchanges": 14248823
}
},
"timestamp": "2015-07-09T11:50:09.171Z"
}
]
var width = 884,
height= 503;
var chart = d3.select("svg")
.attr({
width: width,
height: height
})
.style({
padding : 0
});
function update (data) {
var barWidth = width / data.length;
var yScale = d3
.scale
.linear()
.range([height, 0])
.domain([0, d3.max(data, function (d) {
return d.eventsPerSecond;
})]);
var bars = chart
.selectAll("g")
.data(data);
//ENTER NEW ITEMS
var newBars = bars
.enter()
.append("g");
newBars.append("rect")
newBars.append("text");
bars.attr("transform", function (d, i) {
return "translate(" + i * barWidth + ",0)";
});
//UPDATE ALL ITEMS
bars.selectAll("rect")
.attr({
"y" :function (d) {
return yScale(d.eventsPerSecond);
},
"height": function (d) {
return height - yScale(d.eventsPerSecond);
},
"width" : barWidth -18
})
.style({
"fill": "rgba(174,0,52,1)"
});
bars.selectAll("text")
.attr({
"x" : barWidth / 4,
"y" : function (d) {
return yScale(d.eventsPerSecond) + 5
},
"dy" : ".75em"
})
.style({
"fill" : "rgb(255,255,255)"
})
.text(function (d) {
return d.eventsPerSecond -1;
});
}
var data = tributary.data.map(function (d) {
return {
timestamp: d.timestamp,
eventsPerSecond: d.gauges.itemMatchService.eventsPerSecond + 1
};
});
update(data);
function addData () {
for(var i = 0; i < 10; i++) {
setTimeout(function () {
var measurement = {
timestamp : new Date(),
eventsPerSecond: Math.round(Math.random() * 2000)
};
data.push(measurement);
update(data);
}, 1000);
}
}
//addData()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment