You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// So we can pass the x and y as strings when creating the function
chartObj.xFunct=function(d){returnd[xName]};
// For each yObjs argument, create a yFunction
functiongetYFn(column){
returnfunction(d){
returnd[column];
};
}
// Object instead of array
chartObj.yFuncts=[];
for(varyinyObjs){
yObjs[y].name=y;
yObjs[y].yFunct=getYFn(yObjs[y].column);//Need this list for the ymax function
chartObj.yFuncts.push(yObjs[y].yFunct);
}
//Formatter functions for the axes
chartObj.formatAsDate=d3.time.format("%Y-%m-%d");
chartObj.formatAsNumber=d3.format(".0f");
chartObj.formatAsDecimal=d3.format(".2f");
chartObj.formatAsCurrency=d3.format("$.2f");
chartObj.formatAsFloat=function(d){
if(d%1!==0){
returnd3.format(".2f")(d);
}else{
returnd3.format(".0f")(d);
}
};
chartObj.xFormatter=chartObj.formatAsDate;
chartObj.yFormatter=chartObj.formatAsFloat;
chartObj.bisectYear=d3.bisector(chartObj.xFunct).left;//< Can be overridden in definition
//Create scale functions
// chartObj.xScale = d3.scale.linear().range([0, chartObj.width]).domain(d3.extent(chartObj.data, chartObj.xFunct)); //< Can be overridden in definition
chartObj.xScale=d3.time.scale().range([0,chartObj.width]).domain(d3.extent(chartObj.data,chartObj.xFunct));// values between for month of january