{"version":3,"sources":["webpack:///C:/Dropbox/www/amcharts4dev/node_modules/regression/dist/regression.js","webpack:///../../../../../src/.internal/plugins/regression/Regression.ts","webpack:///./plugins/regression.js"],"names":["__WEBPACK_AMD_DEFINE_FACTORY__","__WEBPACK_AMD_DEFINE_ARRAY__","__WEBPACK_AMD_DEFINE_RESULT__","global","factory","define","module","undefined","apply","exports","this","_extends","Object","assign","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","DEFAULT_OPTIONS","order","precision","period","determinationCoefficient","data","results","predictions","observations","forEach","d","push","mean","reduce","a","observation","ssyy","difference","accum","index","prediction","residual","round","number","factor","Math","pow","methods","linear","options","sum","len","n","run","rise","gradient","intercept","predict","x","points","map","point","equation","r2","string","exponential","log","denominator","exp","b","coeffA","coeffB","logarithmic","power","polynomial","lhs","rhs","k","l","c","j","_l","coefficients","input","matrix","maxrow","abs","tmp","_j","_k","_j2","total","_k2","gaussianElimination","v","coeff","_i","concat","arr","Array","isArray","arr2","from","_toConsumableArray","reverse","keys","accumulator","name","_round","obj","value","defineProperty","enumerable","configurable","writable","_defineProperty","supplied","Regression_Regression","_super","Regression","_this","events","EventDispatcher","_method","_options","_simplify","_reorder","_skipValidatedEvent","tslib_es6","init","processSeries","invalidateData","_disposers","on","ev","calcData","_originalData","adapter","add","_data","series","seriesData","baseSprite","xx","dataFields","valueX","y","valueY","Type","result","method","regression","dispatchImmediately","type","reorder","sort","this_1","simplify","item","xx_1","utils_Object","val","out_i_1","Plugin","Registry","registeredClasses","window","am4plugins_regression","regression_namespaceObject"],"mappings":";;;;;;;;;;;;;;;;;;;0DAAA,IAAAA,EAAAC,EAAAC,GAAA,SAAWC,EAAQC,GAEfC,GAAQC,QAAFC,KAAAL,EAAA,mBAAAF,EAAA,GAAAA,EAAAQ,MAAAC,EAAAR,GAAAD,KAAAM,EAAAG,QAAAP,GAFV,CAYGQ,EAAM,SAAUJ,GACjB,aAiBA,IAAIK,EAAWC,OAAOC,QAAU,SAAUC,GACxC,IAA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AIyI,EAAO1F,OAAO7C,OAAS,GAE5B,IAAIgJ,KACEC,EAAKnG,EAAIhD,GACfoJ,EAAA,KAAaJ,EAAKjJ,OAAOqI,WAAY,SAAChI,EAAKiJ,GAEzCH,EAAKG,GADK,UAAPjJ,EACSqI,EAAO1F,OAAO/C,GAAG,GAEd,UAAPI,EACIqI,EAAO1F,OAAO/C,GAAG,GAGjBiI,EAAWkB,GAAIE,KAG7BL,EAAKjB,MAAM5G,KAAK+H,KAjBRlJ,UAAT,IAASA,EAAI,EAAGA,EAAIyI,EAAO1F,OAAO7C,OAAQF,MAAjCA,KAACsJ,GA8BXzJ,OAAAsG,eAAWQ,EAAAtG,UAAA,cAUX,WACC,OAAOV,KAAKoH,aAXb,SAAkBb,GACbvG,KAAKoH,SAAWb,IACnBvG,KAAKoH,QAAUb,EACfvG,KAAK4H,mDA0BP1H,OAAAsG,eAAWQ,EAAAtG,UAAA,eAUX,WACC,OAAOV,KAAKqH,cAXb,SAAmBd,GACdvG,KAAKqH,UAAYd,IACpBvG,KAAKqH,SAAWd,EAChBvG,KAAK4H,mDAqBP1H,OAAAsG,eAAWQ,EAAAtG,UAAA,gBAUX,WACC,OAAOV,KAAKsH,eAXb,SAAoBf,GACfvG,KAAKsH,WAAaf,IACrBvG,KAAKsH,UAAYf,EACjBvG,KAAK4H,mDAmBP1H,OAAAsG,eAAWQ,EAAAtG,UAAA,eAUX,WACC,OAAOV,KAAKuH,cAXb,SAAmBhB,GACdvG,KAAKuH,UAAYhB,IACpBvG,KAAKuH,SAAWhB,EAChBvG,KAAK4H,mDAWRZ,EA3RA,CAAgC4C,EAAA,GAmShCC,EAAA,EAASC,kBAA8B,WAAIhD,EC1X3CiD,OAAAC,sBAA+BC","file":"./plugins/regression.js","sourcesContent":["(function (global, factory) {\n if (typeof define === \"function\" && define.amd) {\n define(['module'], factory);\n } else if (typeof exports !== \"undefined\") {\n factory(module);\n } else {\n var mod = {\n exports: {}\n };\n factory(mod);\n global.regression = mod.exports;\n }\n})(this, function (module) {\n 'use strict';\n\n function _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n }\n\n var _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n function _toConsumableArray(arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {\n arr2[i] = arr[i];\n }\n\n return arr2;\n } else {\n return Array.from(arr);\n }\n }\n\n var DEFAULT_OPTIONS = { order: 2, precision: 2, period: null };\n\n /**\n * Determine the coefficient of determination (r^2) of a fit from the observations\n * and predictions.\n *\n * @param {Array>} data - Pairs of observed x-y values\n * @param {Array>} results - Pairs of observed predicted x-y values\n *\n * @return {number} - The r^2 value, or NaN if one cannot be calculated.\n */\n function determinationCoefficient(data, results) {\n var predictions = [];\n var observations = [];\n\n data.forEach(function (d, i) {\n if (d[1] !== null) {\n observations.push(d);\n predictions.push(results[i]);\n }\n });\n\n var sum = observations.reduce(function (a, observation) {\n return a + observation[1];\n }, 0);\n var mean = sum / observations.length;\n\n var ssyy = observations.reduce(function (a, observation) {\n var difference = observation[1] - mean;\n return a + difference * difference;\n }, 0);\n\n var sse = observations.reduce(function (accum, observation, index) {\n var prediction = predictions[index];\n var residual = observation[1] - prediction[1];\n return accum + residual * residual;\n }, 0);\n\n return 1 - sse / ssyy;\n }\n\n /**\n * Determine the solution of a system of linear equations A * x = b using\n * Gaussian elimination.\n *\n * @param {Array>} input - A 2-d matrix of data in row-major form [ A | b ]\n * @param {number} order - How many degrees to solve for\n *\n * @return {Array} - Vector of normalized solution coefficients matrix (x)\n */\n function gaussianElimination(input, order) {\n var matrix = input;\n var n = input.length - 1;\n var coefficients = [order];\n\n for (var i = 0; i < n; i++) {\n var maxrow = i;\n for (var j = i + 1; j < n; j++) {\n if (Math.abs(matrix[i][j]) > Math.abs(matrix[i][maxrow])) {\n maxrow = j;\n }\n }\n\n for (var k = i; k < n + 1; k++) {\n var tmp = matrix[k][i];\n matrix[k][i] = matrix[k][maxrow];\n matrix[k][maxrow] = tmp;\n }\n\n for (var _j = i + 1; _j < n; _j++) {\n for (var _k = n; _k >= i; _k--) {\n matrix[_k][_j] -= matrix[_k][i] * matrix[i][_j] / matrix[i][i];\n }\n }\n }\n\n for (var _j2 = n - 1; _j2 >= 0; _j2--) {\n var total = 0;\n for (var _k2 = _j2 + 1; _k2 < n; _k2++) {\n total += matrix[_k2][_j2] * coefficients[_k2];\n }\n\n coefficients[_j2] = (matrix[n][_j2] - total) / matrix[_j2][_j2];\n }\n\n return coefficients;\n }\n\n /**\n * Round a number to a precision, specificed in number of decimal places\n *\n * @param {number} number - The number to round\n * @param {number} precision - The number of decimal places to round to:\n * > 0 means decimals, < 0 means powers of 10\n *\n *\n * @return {numbr} - The number, rounded\n */\n function round(number, precision) {\n var factor = Math.pow(10, precision);\n return Math.round(number * factor) / factor;\n }\n\n /**\n * The set of all fitting methods\n *\n * @namespace\n */\n var methods = {\n linear: function linear(data, options) {\n var sum = [0, 0, 0, 0, 0];\n var len = 0;\n\n for (var n = 0; n < data.length; n++) {\n if (data[n][1] !== null) {\n len++;\n sum[0] += data[n][0];\n sum[1] += data[n][1];\n sum[2] += data[n][0] * data[n][0];\n sum[3] += data[n][0] * data[n][1];\n sum[4] += data[n][1] * data[n][1];\n }\n }\n\n var run = len * sum[2] - sum[0] * sum[0];\n var rise = len * sum[3] - sum[0] * sum[1];\n var gradient = run === 0 ? 0 : round(rise / run, options.precision);\n var intercept = round(sum[1] / len - gradient * sum[0] / len, options.precision);\n\n var predict = function predict(x) {\n return [round(x, options.precision), round(gradient * x + intercept, options.precision)];\n };\n\n var points = data.map(function (point) {\n return predict(point[0]);\n });\n\n return {\n points: points,\n predict: predict,\n equation: [gradient, intercept],\n r2: round(determinationCoefficient(data, points), options.precision),\n string: intercept === 0 ? 'y = ' + gradient + 'x' : 'y = ' + gradient + 'x + ' + intercept\n };\n },\n exponential: function exponential(data, options) {\n var sum = [0, 0, 0, 0, 0, 0];\n\n for (var n = 0; n < data.length; n++) {\n if (data[n][1] !== null) {\n sum[0] += data[n][0];\n sum[1] += data[n][1];\n sum[2] += data[n][0] * data[n][0] * data[n][1];\n sum[3] += data[n][1] * Math.log(data[n][1]);\n sum[4] += data[n][0] * data[n][1] * Math.log(data[n][1]);\n sum[5] += data[n][0] * data[n][1];\n }\n }\n\n var denominator = sum[1] * sum[2] - sum[5] * sum[5];\n var a = Math.exp((sum[2] * sum[3] - sum[5] * sum[4]) / denominator);\n var b = (sum[1] * sum[4] - sum[5] * sum[3]) / denominator;\n var coeffA = round(a, options.precision);\n var coeffB = round(b, options.precision);\n var predict = function predict(x) {\n return [round(x, options.precision), round(coeffA * Math.exp(coeffB * x), options.precision)];\n };\n\n var points = data.map(function (point) {\n return predict(point[0]);\n });\n\n return {\n points: points,\n predict: predict,\n equation: [coeffA, coeffB],\n string: 'y = ' + coeffA + 'e^(' + coeffB + 'x)',\n r2: round(determinationCoefficient(data, points), options.precision)\n };\n },\n logarithmic: function logarithmic(data, options) {\n var sum = [0, 0, 0, 0];\n var len = data.length;\n\n for (var n = 0; n < len; n++) {\n if (data[n][1] !== null) {\n sum[0] += Math.log(data[n][0]);\n sum[1] += data[n][1] * Math.log(data[n][0]);\n sum[2] += data[n][1];\n sum[3] += Math.pow(Math.log(data[n][0]), 2);\n }\n }\n\n var a = (len * sum[1] - sum[2] * sum[0]) / (len * sum[3] - sum[0] * sum[0]);\n var coeffB = round(a, options.precision);\n var coeffA = round((sum[2] - coeffB * sum[0]) / len, options.precision);\n\n var predict = function predict(x) {\n return [round(x, options.precision), round(round(coeffA + coeffB * Math.log(x), options.precision), options.precision)];\n };\n\n var points = data.map(function (point) {\n return predict(point[0]);\n });\n\n return {\n points: points,\n predict: predict,\n equation: [coeffA, coeffB],\n string: 'y = ' + coeffA + ' + ' + coeffB + ' ln(x)',\n r2: round(determinationCoefficient(data, points), options.precision)\n };\n },\n power: function power(data, options) {\n var sum = [0, 0, 0, 0, 0];\n var len = data.length;\n\n for (var n = 0; n < len; n++) {\n if (data[n][1] !== null) {\n sum[0] += Math.log(data[n][0]);\n sum[1] += Math.log(data[n][1]) * Math.log(data[n][0]);\n sum[2] += Math.log(data[n][1]);\n sum[3] += Math.pow(Math.log(data[n][0]), 2);\n }\n }\n\n var b = (len * sum[1] - sum[0] * sum[2]) / (len * sum[3] - Math.pow(sum[0], 2));\n var a = (sum[2] - b * sum[0]) / len;\n var coeffA = round(Math.exp(a), options.precision);\n var coeffB = round(b, options.precision);\n\n var predict = function predict(x) {\n return [round(x, options.precision), round(round(coeffA * Math.pow(x, coeffB), options.precision), options.precision)];\n };\n\n var points = data.map(function (point) {\n return predict(point[0]);\n });\n\n return {\n points: points,\n predict: predict,\n equation: [coeffA, coeffB],\n string: 'y = ' + coeffA + 'x^' + coeffB,\n r2: round(determinationCoefficient(data, points), options.precision)\n };\n },\n polynomial: function polynomial(data, options) {\n var lhs = [];\n var rhs = [];\n var a = 0;\n var b = 0;\n var len = data.length;\n var k = options.order + 1;\n\n for (var i = 0; i < k; i++) {\n for (var l = 0; l < len; l++) {\n if (data[l][1] !== null) {\n a += Math.pow(data[l][0], i) * data[l][1];\n }\n }\n\n lhs.push(a);\n a = 0;\n\n var c = [];\n for (var j = 0; j < k; j++) {\n for (var _l = 0; _l < len; _l++) {\n if (data[_l][1] !== null) {\n b += Math.pow(data[_l][0], i + j);\n }\n }\n c.push(b);\n b = 0;\n }\n rhs.push(c);\n }\n rhs.push(lhs);\n\n var coefficients = gaussianElimination(rhs, k).map(function (v) {\n return round(v, options.precision);\n });\n\n var predict = function predict(x) {\n return [round(x, options.precision), round(coefficients.reduce(function (sum, coeff, power) {\n return sum + coeff * Math.pow(x, power);\n }, 0), options.precision)];\n };\n\n var points = data.map(function (point) {\n return predict(point[0]);\n });\n\n var string = 'y = ';\n for (var _i = coefficients.length - 1; _i >= 0; _i--) {\n if (_i > 1) {\n string += coefficients[_i] + 'x^' + _i + ' + ';\n } else if (_i === 1) {\n string += coefficients[_i] + 'x + ';\n } else {\n string += coefficients[_i];\n }\n }\n\n return {\n string: string,\n points: points,\n predict: predict,\n equation: [].concat(_toConsumableArray(coefficients)).reverse(),\n r2: round(determinationCoefficient(data, points), options.precision)\n };\n }\n };\n\n function createWrapper() {\n var reduce = function reduce(accumulator, name) {\n return _extends({\n _round: round\n }, accumulator, _defineProperty({}, name, function (data, supplied) {\n return methods[name](data, _extends({}, DEFAULT_OPTIONS, supplied));\n }));\n };\n\n return Object.keys(methods).reduce(reduce, {});\n }\n\n module.exports = createWrapper();\n});\n\n\n\n// WEBPACK FOOTER //\n// C:/Dropbox/www/amcharts4dev/node_modules/regression/dist/regression.js","/**\r\n * Regression plugin.\r\n *\r\n * Uses regression-js library by Tom Alexander\r\n * http://tom-alexander.github.io/regression-js/\r\n */\r\n\r\n/**\r\n * ============================================================================\r\n * IMPORTS\r\n * ============================================================================\r\n * @hidden\r\n */\r\nimport * as regression from \"regression\";\r\nimport { Plugin } from \"../../core/utils/Plugin\";\r\nimport { XYSeries } from \"../../charts/series/XYSeries\";\r\nimport { Optional } from \"../../core/utils/Type\";\r\nimport { registry } from \"../../core/Registry\";\r\nimport { EventDispatcher, AMEvent } from \"../../core/utils/EventDispatcher\";\r\nimport * as $object from \"../../core/utils/Object\";\r\nimport * as $type from \"../../core/utils/Type\";\r\n\r\n/**\r\n * Defines events for [[BaseObjectEvents]].\r\n */\r\nexport interface IRegressionEvents {\r\n\t/**\r\n\t * Invoked when regression finishes calculating data.\r\n\t */\r\n\tprocessed: {};\r\n};\r\n\r\n\r\n\r\n/**\r\n * ============================================================================\r\n * MAIN CLASS\r\n * ============================================================================\r\n * @hidden\r\n */\r\n\r\n/**\r\n * A module which automatically calculates data for for trend lines using\r\n * various regression algorithms.\r\n *\r\n * By pushing an instance of [[Regression]] into `plugin` list of\r\n * any [[XYSeries]], it automatically recalculates and overrides its\r\n * data to show regression trend line, inestead of the source values.\r\n *\r\n * Example:\r\n *\r\n * ```TypeScript\r\n * let regseries = chart.series.push(new am4charts.LineSeries());\r\n * regseries.dataFields.valueY = \"value\";\r\n * regseries.dataFields.dateX = \"date\";\r\n *\r\n * let reg = regseries.plugins.push(new am4plugins_regression.Regression());\r\n * reg.method = \"polynomial\";\r\n * ```\r\n * ```JavaScript\r\n * var regseries = chart.series.push(new am4charts.LineSeries());\r\n * regseries.dataFields.valueY = \"value\";\r\n * regseries.dataFields.dateX = \"date\";\r\n *\r\n * var reg = regseries.plugins.push(new am4plugins_regression.Regression());\r\n * reg.method = \"polynomial\";\r\n * ```\r\n * ```JSON\r\n * {\r\n * // ...\r\n * \"series\": [{\r\n * // ...\r\n * }, {\r\n * \"type\": \"LineSeries\",\r\n * \"dataFields\": {\r\n * \"valueY\": \"value\",\r\n * \"dateX\": \"date\"\r\n * },\r\n * \"plugins\": [{\r\n * \"type\": \"Regression\",\r\n * \"method\": \"polynomial\"\r\n * }]\r\n * }]\r\n * }\r\n * ```\r\n *\r\n * @since 4.2.2\r\n */\r\nexport class Regression extends Plugin {\r\n\r\n\t/**\r\n\t * A series object that will be used for the trend line.\r\n\t */\r\n\tpublic target: Optional;\r\n\r\n\t/**\r\n\t * An [[EventDispatcher]] instance.\r\n\t *\r\n\t * @since 4.3.14\r\n\t */\r\n\tpublic events: EventDispatcher> = new EventDispatcher();\r\n\r\n\t/**\r\n\t * Method\r\n\t */\r\n\tprotected _method: \"linear\" | \"polynomial\" = \"linear\";\r\n\r\n\t/**\r\n\t * Options\r\n\t */\r\n\tprotected _options: { [index: string]: any } = {};\r\n\r\n\t/**\r\n\t * Simplify output data.\r\n\t */\r\n\tprotected _simplify: boolean = false;\r\n\r\n\t/**\r\n\t * Reorder data after calculation\r\n\t */\r\n\tprotected _reorder: boolean = false;\r\n\r\n\t/**\r\n\t * Calculated data.\r\n\t */\r\n\tprotected _data: Optional;\r\n\r\n\t/**\r\n\t * An object containing results of the calculation.\r\n\t *\r\n\t * @since 4.3.14\r\n\t */\r\n\tpublic result: Optional;\r\n\r\n\t/**\r\n\t * Original series data.\r\n\t */\r\n\tprotected _originalData: Optional;\r\n\r\n\t/**\r\n\t * Should skip next \"beforedatavalidated\" event?\r\n\t */\r\n\tprotected _skipValidatedEvent: boolean = false;\r\n\r\n\t/**\r\n\t * Constructor\r\n\t */\r\n\tconstructor() {\r\n\t\t// Nothing to do here\r\n\t\tsuper();\r\n\t}\r\n\r\n\tpublic init() {\r\n\t\tsuper.init();\r\n\t\tthis.processSeries();\r\n\t}\r\n\r\n\t/**\r\n\t * Decorates series with required events and adapters used to hijack its\r\n\t * data.\r\n\t */\r\n\tprivate processSeries(): void {\r\n\r\n\t\tthis.invalidateData();\r\n\r\n\t\t// Invalidate calculated data whenever data updates\r\n\t\tthis._disposers.push(this.target.events.on(\"beforedatavalidated\", (ev) => {\r\n\t\t\tif (this._skipValidatedEvent) {\r\n\t\t\t\tthis._skipValidatedEvent = false;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\t\t\tthis.calcData();\r\n\t\t}));\r\n\r\n\t\t// Save original series data\r\n\t\tif (this.target.data && this.target.data.length) {\r\n\t\t\tthis._originalData = this.target.data;\r\n\t\t}\r\n\r\n\t\t// Set up adpater for data\r\n\t\tthis.target.adapter.add(\"data\", () => {\r\n\t\t\tif (this._data === undefined) {\r\n\t\t\t\tthis.calcData();\r\n\t\t\t}\r\n\t\t\treturn this._data;\r\n\t\t});\r\n\t}\r\n\r\n\tprivate invalidateData(): void {\r\n\t\tthis._data = undefined;\r\n\t}\r\n\r\n\tprivate calcData(): void {\r\n\t\tthis._data = [];\r\n\t\tconst series = this.target;\r\n\r\n\t\t// Get series' data (global or series own)\r\n\t\tlet seriesData: any = this._originalData;\r\n\t\tif (!seriesData || seriesData.length == 0) {\r\n\t\t\tseriesData = (this.target.baseSprite).data;\r\n\t\t}\r\n\r\n\t\t// Build matrix for the regression function\r\n\t\tlet matrix: any = [];\r\n\t\tlet map: any = {};\r\n\t\tlet xx = 0;\r\n\t\tfor (let i = 0; i < seriesData.length; i++) {\r\n\t\t\tlet x = series.dataFields.valueX ? seriesData[i][series.dataFields.valueX] : i;\r\n\t\t\tlet y = series.dataFields.valueY ? seriesData[i][series.dataFields.valueY] : i;\r\n\t\t\tif ($type.hasValue(x) && $type.hasValue(y)) {\r\n\t\t\t\tmatrix.push([x, y]);\r\n\t\t\t\tmap[xx] = i;\r\n\t\t\t\txx++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t// Calculate regression values\r\n\t\tlet result: any = [];\r\n\t\tswitch (this.method) {\r\n\t\t\tcase \"polynomial\":\r\n\t\t\t\tresult = regression.polynomial(matrix, this.options);\r\n\t\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\t\tresult = regression.linear(matrix, this.options);\r\n\t\t}\r\n\r\n\t\t// Set results\r\n\t\tthis.result = result;\r\n\r\n\t\t// Invoke event\r\n\t\tthis.events.dispatchImmediately(\"processed\", {\r\n\t\t\ttype: \"processed\",\r\n\t\t\ttarget: this\r\n\t\t});\r\n\r\n\t\t// Order data points\r\n\t\tif (this.reorder) {\r\n\t\t\tresult.points.sort(function(a: any, b: any) {\r\n\t\t\t\tif (a[0] > b[0]) {\r\n\t\t\t\t\treturn -1;\r\n\t\t\t\t}\r\n\t\t\t\telse if (a[0] < b[0]) {\r\n\t\t\t\t\treturn 1;\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\treturn 0;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t// Build data\r\n\t\tthis._data = [];\r\n\t\tfor (let i = 0; i < result.points.length; i++) {\r\n\t\t\tif (this.simplify && i) {\r\n\t\t\t\ti = result.points.length - 1;\r\n\t\t\t}\r\n\t\t\tlet item: any = {};\r\n\t\t\tconst xx = map[i];\r\n\t\t\t$object.each(this.target.dataFields, (key, val) => {\r\n\t\t\t\tif (key == \"valueX\") {\r\n\t\t\t\t\titem[val] = result.points[i][0];\r\n\t\t\t\t}\r\n\t\t\t\telse if (key == \"valueY\") {\r\n\t\t\t\t\titem[val] = result.points[i][1];\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\titem[val] = seriesData[xx][val];\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tthis._data.push(item);\r\n\t\t}\r\n\r\n\t}\r\n\r\n\t/**\r\n\t * Method to calculate regression.\r\n\t *\r\n\t * Supported values: \"linear\" (default), \"polynomial\".\r\n\t *\r\n\t * @default linear\r\n\t * @param value Method\r\n\t */\r\n\tpublic set method(value: \"linear\" | \"polynomial\") {\r\n\t\tif (this._method != value) {\r\n\t\t\tthis._method = value;\r\n\t\t\tthis.invalidateData();\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * @return Method\r\n\t */\r\n\tpublic get method(): \"linear\" | \"polynomial\" {\r\n\t\treturn this._method;\r\n\t}\r\n\r\n\t/**\r\n\t * Regression output options.\r\n\t *\r\n\t * Below are default values.\r\n\t *\r\n\t * ```JSON\r\n\t * {\r\n\t * order: 2,\r\n\t * precision: 2,\r\n\t * }\r\n\t * ```\r\n\t *\r\n\t * @see {@link https://github.com/Tom-Alexander/regression-js#configuration-options} About options\r\n\t * @param value Options\r\n\t */\r\n\tpublic set options(value: { [index: string]: any }) {\r\n\t\tif (this._options != value) {\r\n\t\t\tthis._options = value;\r\n\t\t\tthis.invalidateData();\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * @return Options\r\n\t */\r\n\tpublic get options(): { [index: string]: any } {\r\n\t\treturn this._options;\r\n\t}\r\n\r\n\t/**\r\n\t * Simplify regression line data? If set to `true` it will use only two\r\n\t * result data points: first and last.\r\n\t *\r\n\t * NOTE: this does make sense with \"linear\" method only.\r\n\t *\r\n\t * @default false\r\n\t * @since 4.2.3\r\n\t * @param value Simplify?\r\n\t */\r\n\tpublic set simplify(value: boolean) {\r\n\t\tif (this._simplify != value) {\r\n\t\t\tthis._simplify = value;\r\n\t\t\tthis.invalidateData();\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * @return Simplify?\r\n\t */\r\n\tpublic get simplify(): boolean {\r\n\t\treturn this._simplify;\r\n\t}\r\n\r\n\t/**\r\n\t * Orders data points after calculation. This can make sense in scatter plot\r\n\t * scenarios where data points can come in non-linear fashion.\r\n\t *\r\n\t * @default false\r\n\t * @since 4.2.3\r\n\t * @param value Reorder data?\r\n\t */\r\n\tpublic set reorder(value: boolean) {\r\n\t\tif (this._reorder != value) {\r\n\t\t\tthis._reorder = value;\r\n\t\t\tthis.invalidateData();\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * @return Reorder data?\r\n\t */\r\n\tpublic get reorder(): boolean {\r\n\t\treturn this._reorder;\r\n\t}\r\n\r\n}\r\n\r\n/**\r\n * Register class in system, so that it can be instantiated using its name from\r\n * anywhere.\r\n *\r\n * @ignore\r\n */\r\nregistry.registeredClasses[\"Regression\"] = Regression;\r\n\n\n\n// WEBPACK FOOTER //\n// ../../../../../src/.internal/plugins/regression/Regression.ts","import * as m from \"../../es2015/plugins/regression\";\nwindow.am4plugins_regression = m;\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./plugins/regression.js\n// module id = null\n// module chunks = "],"sourceRoot":""}