The trend is not displayed when using bestFitLine and dataloader plugins
-
The trend is not displayed when using bestFitLine and dataloader plugins
1. Have: Local Server Ubuntu 16.04 Windows Client with Google Chrome CMS WordPress 4.9.6; Latest Plugins: amcharts-charts-and-maps; dataloader bestFitLine 2. Let's consider a somewhat simplified example of a temporary chart with a trend line from https://codepen.io/team/amcharts/pen/0fc47f492f01aa42c3755e7da4a181f0. html <script src="https://www.amcharts.com/lib/3/amcharts.js"></script> <script src="https://www.amcharts.com/lib/3/serial.js"></script> <script src="https://www.amcharts.com/lib/3/themes/light.js"></script> <script src="https://www.amcharts.com/lib/3/plugins/tools/bestFitLine/bestFitLine.min.js"></script> <div id="chartdiv" style="width: 100%; height: 500px;"></div> js var chart = AmCharts.makeChart("chartdiv", { "type": "serial", "legend": { "useGraphSettings": true }, "dataDateFormat": "YYYY-MM-DD", "valueAxes": [{ "id": "v1", "axisAlpha": 0, "position": "left", "ignoreAxisWidth": true }], "graphs": [{ "valueAxis": "v1", "bullet": "square", "bulletSize": 5, "valueField": "value", "fillAlphas": 0, "bestFitLine": { "lineColor": "#cc0000", "lineAlpha": 0.8, "lineThickness": 2 } }], "categoryField": "date", "categoryAxis": { "parseDates": true, "dashLength": 1, "minorGridEnabled": true }, "chartScrollbar": {}, "chartCursor": { "cursorPosition": "date" }, "dataProvider": [{ "date": "2012-12-16", "value": 64 }, { "date": "2012-12-17", "value": 61 }, ..., { "date": "2013-01-30", "value": 81 }] }); Load the same data in JSON format using dataloader html <script src="https://www.amcharts.com/lib/3/amcharts.js"></script> <script src="https://www.amcharts.com/lib/3/serial.js"></script> <script src="https://www.amcharts.com/lib/3/themes/light.js"></script> <script src="https://www.amcharts.com/lib/3/plugins/tools/bestFitLine/bestFitLine.min.js"></script> <script src="https://www.amcharts.com/lib/3/plugins/dataloader/dataloader.min.js"></script> <div id="chartdiv" style="width: 100%; height: 500px;"></div> js var chart = AmCharts.makeChart("chartdiv", { "type": "serial", "legend": { "useGraphSettings": true }, "DateFormat": "YYYY-MM-DD", "dataLoader": { "url": "/json-data/ trend_data.json", "showErrors": true, "complete": function ( chart ) { console.log( "Loading complete" ); }, "load": function ( options, chart ) { console.log( "File loaded: ", options.url ); }, "error": function ( options, chart ) { console.log( "Error occured loading file: ", options.url ); }, "async": true }, "valueAxes": [{ "id": "v1", "axisAlpha": 0, "position": "left", "ignoreAxisWidth": true }], "graphs": [{ "valueAxis": "v1", "bullet": "square", "bulletSize": 5, "valueField": "value", "fillAlphas": 0, "bestFitLine": { "lineColor": "#cc0000", "lineAlpha": 0.8, "lineThickness": 2 } }], "categoryField": "date", "categoryAxis": { "parseDates": true, "dashLength": 1, "minorGridEnabled": true }, "chartScrollbar": {}, "chartCursor": { "cursorPosition": "date" } }); chart.addListener("dataUpdated", zoomChart); zoomChart(); function zoomChart(){ chart.zoomToIndexes(chart.dataProvider.length - 20, chart.dataProvider.length - 1); } The same json data file has the form: [{"date":"2012-12-16","value":64},{"date":"2012-12-17","value":61}, ..., {"date":"2013-01-30", "value":81}] As a result we have the same chart, but without a trend line. Please tell how to fix this problem.
Thank you
- The topic ‘The trend is not displayed when using bestFitLine and dataloader plugins’ is closed to new replies.