I am in my rookie stage learning javascript. I made an API that gets a number of users registered on a certain date and returns this data as a JSON object. Here is a sample of that data
{"myjsonobject": [{"users": 3, "joined": "2013-05-25"}, {"users": 1, "joined": "2013-05-26"}, {"users": 1, "joined": "2013-05-30"}, {"users": 1, "joined": "2013-05-31"}]}
I then parse the data and graph on ChartJS linegraph using the javascript function below
$(document).ready(function()
{
url = "http://mylink/getjson/"
Create_jsonObject(url)
});
function Create_jsonObject(url) {
$.getJSON(url, function (data) {
myJSONObject=data;
var dataSource=myJSONObject.myjsonoject;
var chart = $("#chartContainer").dxChart({
dataSource: dataSource,
commonSeriesSettings: {
argumentField: 'joined'
},
series: [
{ valueField: 'users', name: 'users' },
],
argumentAxis:{
grid:{
visible: true
}
},
tooltip:{
enabled: true
},
title: 'Volunteer Registration',
legend: {
verticalAlignment: 'bottom',
horizontalAlignment: 'center'
},
commonPaneSettings: {
border:{
visible: true,
right: false
}
}
});
});
};
The function works in charting the JSON data on the linegraph. I would like to incorporate a javascript function that checks for missing dates and inserts 0 users where a date is missing. Thus the graph will plot zero where not date was returned. It should check this against the earliest date returned. Any ideas anyone?
Thanks