I have the following code that gets data from a database and plots a graph using HTML and the FusionCharts library. I'm just having some trouble with the graph formatting. I want the yAxisMin to be 10 values below the minimum value in the data array and the yAxisMax value to be 10 values above.
function createJSON(name, data){
return(
{
"chart": {
"caption": String(name),
"subCaption": "15-Day Prices",
"xAxisName": "Day",
"yAxisName": "Price (USD)",
"anchorRadius": "1",
"showValues": "0",
"borderThickness": "3",
"yAxisMinValue": data.value.min() - 10,
"yAxisMaxValue": data.value.max() + 10,
"theme": "fint"
},
"data": data,
}
);
}
//I'm including this for context. This is the function that returns the data array
var getHistory = function(req,res,next){
var data = [];
History.findOne({"Symbol": String(req.params.sym)}, function(err, foundHistory){
if(foundHistory){
(foundHistory.Historical).forEach(function(day){
data.push({
"label": day.Date,
"value": day.Close
});
});
res.json(createJSON(foundHistory.Name, data));
next();
}
else{
next();
}
});
};
module.exports = getHistory;
Everything else works fine. I just need help with the two lines of code:
"yAxisMinValue": data.value.min() - 10,
"yAxisMaxValue": data.value.max() + 10,
How would I do this? This was my attempt but it does not compile.