Skip to content

Commit

Permalink
More changes for the frontend using dc.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Mircea Danila Dumitrescu committed May 28, 2014
1 parent a3daaf2 commit 0e35feb
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion bin/generator-config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions examples/event-stream/event-get.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,25 @@ <h1>Streaming Events</h1>
}
}
if (type) {

socket = new WebSocket("ws://localhost:1081/1.0/event/get");
socket.onopen = function () {
console.log("connected!");
socket.send(JSON.stringify({
type: type,
start: new Date().getTime()-60*1000
start: new Date().getTime()-1*1000
}));
};

socket.onmessage = function (message) {
var event;
if (message) {
console.log(index++);
//console.log(message);
console.log(message);
if (message.data) {
event = JSON.parse(message.data);
//console.log("received", message.data);
console.log("received", message.data);
if (event && event.data) {
//console.log("received", event.data);
console.log("received", event.data);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions examples/event-stream/event-put.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ <h1>Streaming Events - Put</h1>
}
}));
index++;
if (index % 100 === 0) {
if (index % 10 === 0) {
console.log("sent", index);
}
}, 5);
}, 100);
};

socket.onmessage = function (message) {
Expand Down
1 change: 1 addition & 0 deletions lib/analytics/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ exports.putterInit = function (db, options) {
// then append this events to the queue for later save.
if (eventsCollectionCreated === 0.5) {
eventsToSave = eventsToSave.concat(events);
return;
}
eventsCollectionCreated = 0.5;

Expand Down
4 changes: 2 additions & 2 deletions lib/analytics/genericCounter.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ function customQuery(collectionObj, filter, limit, streamified, messageSender) {
//move filter to cover just the last 5 seconds
temp = new Date().getTime();
temp = temp - temp % 1000 - 5000;
filter._id.$gte= myutils.objectIdFromDate(temp);
filter._id.$lt= myutils.objectIdFromDate(temp+1000);
filter._id.$gte = myutils.objectIdFromDate(temp);
filter._id.$lt = myutils.objectIdFromDate(temp + 1000);
customQuery(collectionObj, filter, limit, streamified, messageSender);
},
1000
Expand Down
90 changes: 45 additions & 45 deletions public/js/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function Chart(config) {
this.resume = function () {
setTimeout(function () {
that.intervalHandle = setInterval(function () {
that.refreshAll();
dc.redrawAll();
}, config.refreshFrequency);
}, 1e3);
};
Expand Down Expand Up @@ -213,7 +213,7 @@ function Chart(config) {
});
this.crossfilter.remove();
this.dimensionTime.filterAll();
this.refreshAll();
// this.refreshAll();
}
};

Expand Down Expand Up @@ -349,50 +349,50 @@ function AggregatedChart(config) {
AggregatedChart.prototype = Chart;

var chartsConfig = [
// {
// name: "T1 Aggregations",
// chartType: "AggregatedChart", //can be "EventsChart" or "AggregatedChart" - meaning one or multiple dimensions
// renderingType: "xxx", //choose a style
// chartParams: {
// length: 3600 * 1e3, //1 hour
// wsAddress: "ws://localhost:1081/1.0/aggregation/get",
// query: {name: "agg1_1m"},
// start: new Date(new Date().getTime() - 3600 * 1e3), //miliseconds ago
// stop: null, //null for a streaming chart
// dimensionsNames: {
// "v1": "Gender",
// "v2": "Platform",
// "v3": "Country"
// },
// metricsNames: {
// c: "Count",
// rt: "Response time"
// }
// },
// refreshFrequency: 10 * 1e3
// }
{
name: "T1 Events",
chartType: "EventsChart", //can be "EventsChart" or "AggregatedChart" - meaning one or multiple dimensions
renderingType: "xxx", //choose a style
chartParams: {
length: 1e3,
wsAddress: "ws://localhost:1081/1.0/event/get",
query: {type: "t1"},
start: new Date(new Date().getTime() - 60 * 1e3), //miliseconds ago
stop: null, //null for a streaming chart
dimensionsNames: {
"v1": "Gender",
"v2": "Platform",
"v3": "Country"
},
metricsNames: {
c: "Count",
rt: "Response time"
// {
// name: "T1 Aggregations",
// chartType: "AggregatedChart", //can be "EventsChart" or "AggregatedChart" - meaning one or multiple dimensions
// renderingType: "xxx", //choose a style
// chartParams: {
// length: 3600 * 1e3, //1 hour
// wsAddress: "ws://localhost:1081/1.0/aggregation/get",
// query: {name: "agg1_1m"},
// start: new Date(new Date().getTime() - 3600 * 1e3), //miliseconds ago
// stop: null, //null for a streaming chart
// dimensionsNames: {
// "v1": "Gender",
// "v2": "Platform",
// "v3": "Country"
// },
// metricsNames: {
// c: "Count",
// rt: "Response time"
// }
// },
// refreshFrequency: 10 * 1e3
// }
{
name: "T1 Events",
chartType: "EventsChart", //can be "EventsChart" or "AggregatedChart" - meaning one or multiple dimensions
renderingType: "xxx", //choose a style
chartParams: {
length: 60 * 1e3,
wsAddress: "ws://localhost:1081/1.0/event/get",
query: {type: "t1"},
start: new Date(new Date().getTime() - 60 * 1e3), //miliseconds ago
stop: null, //null for a streaming chart
dimensionsNames: {
"v1": "Gender",
"v2": "Platform",
"v3": "Country"
},
metricsNames: {
c: "Count",
rt: "Response time"
}
},
refreshFrequency: 1e3
}
},
refreshFrequency: 1e3
}
],
charts = [],
i;
Expand Down

0 comments on commit 0e35feb

Please sign in to comment.