I'm trying to load data into some charts in the ng2-admin template using an API running on another server (or port to be exact).
My code inside the lineChart.service.ts is as follows:
return {
type: 'serial',
theme: 'blur',
marginTop: 15,
marginRight: 15,
responsive: {
'enabled': true
},
dataLoader: {
url: 'http://localhost:4000/reporting/temperatures',
format: 'json',
showErrors: true,
noStyles: true,
async: true
},
categoryField: 'MeasureMoment',
categoryAxis: {
parseDates: true,
gridAlpha: 0,
inside: true,
color: layoutColors.defaultText,
axisColor: layoutColors.defaultText
},
valueAxes: [
{
minVerticalGap: 50,
gridAlpha: 0,
color: layoutColors.defaultText,
axisColor: layoutColors.defaultText,
labelFunction: this.formatLabel
}
],
graphs: [
{
id: 'g0',
bullet: 'none',
useLineColorForBulletBorder: true,
lineColor: colorHelper.hexToRgbA(graphColor, 0.3),
lineThickness: 1,
negativeLineColor: layoutColors.danger,
type: 'smoothedLine',
valueField: 'Temperature',
fillAlphas: 1,
fillColorsField: 'lineColor'
}
],
chartCursor: {
categoryBalloonDateFormat: 'MM YYYY',
categoryBalloonColor: '#4285F4',
categoryBalloonAlpha: 0.7,
cursorAlpha: 0,
valueLineEnabled: true,
valueLineBalloonEnabled: true,
valueLineAlpha: 0.5
},
dataDateFormat: 'MM YYYY',
export: {
enabled: true
},
creditsPosition: 'bottom-right',
zoomOutButton: {
backgroundColor: '#fff',
backgroundAlpha: 0
},
zoomOutText: '',
pathToImages: layoutPaths.images.amChart
};
This is not much other than the default page, except for the part of the data, where in the original template there is a dataProvider element with the data in it and I replaced that by a dataLoader, which I've used successfully before.
I replaced the valueField and CategoryField values by the elements my API returns. As far as I know that should do the trick. When I reload the page I don't see any chart.
I've tested the API, which returns data. I added a log row to the console every time the API is called showing a request is made. I see no requests being made when the ng2-admin page reloads.
When I make some error and see an error message I could look into that, but there's no error message whatsoever.
I could use some help figuring this one out. If more information is needed I'll be glad to share.
Thanks!