Example won't work
Greetings,
Im currently doing my internship to finish my studies. My assignment is to develop a solution to monitor calls which are stored in a .csv file which has atm still kinda a basic structure.
Calls.csv:
Call_Portal,Call_Object,Call_Method,Call_ammount,Call_Querytime,CPU Umicore_Gold,Customers,Get All Customers,1,3.05,3.6 Sygis,Customers,Insert Customer,1,5.06,3.5 ...
I want to show the average querytime grouped by month however im not getting the correct results.
var queryAvgByMonthGroup = moveMonths.group().reduce(
function (p, v) {
++p.days;
p.total += (+v["Call_querytime"]);
p.calls += (+v["Call_ammount"]);
p.avg = (p.total / p.days);
return p;
},
function (p, v) {
--p.days;
p.total -= (+v["Call_querytime"]);
p.calls -= (+v["Call_ammount"]);
p.avg = (p.total / p.days);
return p;
},
function () {
return {days: 0,total: 0, avg: 0 };
}
);
Any chance you could help me out ?
Thanks in advance !
Pieter
I dont see anything wrong other than the "Call_querytime" should be "Call_Querytime". What do you get in debugger if you run queryAvgByMonthGroup.all()?
I have fixed the previous problem however now i need to use a json file which i create from a sql query.
I receive the following data:
[["3","Total_Refinery","Klanten","Get All Klanten","Pieter","5.17","14.02","14/03/201","1"], ["4","Total_Oil\u0026Gas","Klanten","Get All Klanten","Nathan","4.02","9.89","8/03/2013","1"], ["5","Total_Oil\u0026Gas","Klanten","Insert Klant","Nathan","3.89","4.07","4/03/2013","1"], ["6","Total_Oil\u0026Gas","Klanten","Update Klant","Joey","6.76","3.47","3/03/2013","1"], ["7","Total_Oil\u0026Gas","Klanten","Delete Klant","Pieter","2.98","2.12","21/03/201","1"],["8","Total_Refinery","Klanten","Update Klant","Pieter","7.29","7.84","1/03/2013","1"],["9","Total_Refinery","Klanten","Delete Klant","Luc","4.24","3.66","4/02/2013","1"],["10","Sygis_Portaal","Orders","Get Order By ID","Sasha","3.49","8.89","14/02/201","1"],["11","Sygis_Portaal","Orders","Get All Orders","Sasha","3.29","4.14","24/02/201","1"],["12","Umicore_Copper","Producten","Get All Producten","Pieter","0.44","1.17","18/02/201","1"],["13","Umicore_Copper","Producten","Get All Producten Gold","Joey","4.69","1.22","14/01/201","1"],["14","Umicore_Copper","Producten","Get All Producten Copper","Nathan","0.84","3.23","7/03/2013","1"],["15","Umicore_Gold","Producten","Get All Producten","Nathan","1.11","4.41","28/03/201","1"],["16","Umicore_Gold","Producten","Get All Producten Gold","Nathan","1.44","6.22","16/03/201","1"],["18","Umicore_Gold","Producten","Get All Producten Copper","Luc","1.29","3.02","14/02/201","1"],["19","Umicore_Gold","Sales","Get All Sales","Pieter","3.02","7.04","18/03/201","1"],["20","Umicore_Gold","Sales","Get Sale By ID","Sasha","3.36","11.01","26/03/201","1"],["23","Umicore_Copper","Sales","Get All Sales","Nathan","7.04","2.02","14/03/201","1"],["24","Umicore_Copper","Sales","Get Sale By ID","Luc","6.01","3.04","14/03/201","1"], ["25","Total_Refinery","Klanten","Get All Klanten","Yves","5.28","14.4","14/03/201","1"],["26","Total_Oil\u0026Gas","Klanten","Get All Klanten","Yves","3.27","8.87","14/03/201","1"]]
Im ablo to generate some basic pie charts however the volume chart wont work.
d3.json(url,function (data) {
var dateFormat = d3.time.format("%m/%d/%Y");
var numberFormat = d3.format(".2f");
data.forEach(function (e) {
e.dd = dateFormat.parse(e[7]);
e.month = d3.time.month(e.dd); // pre-calculate month for better performance
});
// feed it through crossfilter
var calls = crossfilter(data);
var all = calls.groupAll();
var portaal = calls.dimension(function (d) {
return d[1];
});
var portaalGroup = portaal.group();
var moveMonths = calls.dimension(function (d) {
return d.month;
});
var volumeByMonthGroup = moveMonths.group().reduceSum(function (d) {
return d[8];
});
portaalChart.width(200)
.height(200)
.radius(100)
.innerRadius(30)
.dimension(portaal)
.group(portaalGroup)
.label(function (d) {
return d.data.key;
});
volumeChart.width(1200)
.height(200)
.margins({ top: 0, right: 50, bottom: 20, left: 40 })
.dimension(moveMonths)
.group(volumeByMonthGroup)
.centerBar(false)
.gap(0)
.x(d3.time.scale().domain([new Date(2005, 0, 1), new Date(2012, 11, 31)]))
.round(d3.time.month.round)
.xUnits(d3.time.months)
.title(function (d) { return "Value: " + d.value.ammount; })
.elasticY(true);
dc.renderAll();

Could you have a look at it ? Thanks in advance !
I opened my project today and it works now didn't changed anything to the code strange tho :+1:
Only if every problem can be fixed this way =)