I am trying to get an array of objects from an API endpoint inside of a mongo DB. The trouble I am having is what syntax to use to plug in that data, and then get the chart to display that data from the DB.
Here is my array in the mongo shell and the same shows up in ARC so I know my back-end logic is good, the problem is bring it to the view (on the chart).
The x-axis will display the "_id" (so the dates will show on the bottom), and the y-axis will display the "count".
Here is what I have inside of my controller.
vm.lineChartOptions = {
chart: {
type: 'cumulativeLineChart',
height: 450,
margin: {
top: 20,
right: 20,
bottom: 60,
left: 65
},
x: function (d) { return d._id; },
y: function (d) { return d.count; },
color: d3.scale.category10().range(),
duration: 300,
useInteractiveGuideline: true,
clipVoronoi: false,
xAxis: {
axisLabel: 'Reservations',
tickFormat: function (d) {
return d3.time.format('%m/%d/%y')(new Date(d))
},
showMaxMin: false,
staggerLabels: true,
},
yAxis: {
axisLabel: 'Non-reservations',
tickFormat: function (d) {
return d3.format('.2')(d);
},
axisLabelDistance: 20
},
xDomain: [vm.xMinValue, vm.xMaxValue],
yDomain: [customerMetrics.count]
}
};
vm.lineChartData = [
{
key: "Reservations",
values: [[customerMetrics._id, customerMetrics.count]]
,
mean: 250
}