PageSourceSearch

https://www.pyrenees-bearnaises.com/app/dist/pyreneesbearnaises/ad…/es-modules/Series/Spline/SplineSeries.js

js pyrenees-bearnaises.com collected 2026-10-02 15:35:26 UTC 9,178 bytes, 272 lines download raw bytes

vendor: 5,021 bytes, lines 1-138
1/* *
2 *
3 *  (c) 2010-2024 Torstein Honsi
4 *
5 *  License: www.highcharts.com/license
6 *
7 *  !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
8 *
9 * */
10'use strict';
11import SeriesRegistry from '../../Core/Series/SeriesRegistry.js';
12const { line: LineSeries } = SeriesRegistry.seriesTypes;
13import U from '../../Core/Utilities.js';
14const { merge, pick } = U;
15/* *
16 *
17 *  Class
18 *
19 * */
20/**
21 * Spline series type.
22 *
23 * @private
24 */
25class SplineSeries extends LineSeries {
26    /* *
27     *
28     *  Functions
29     *
30     * */
31    /* eslint-disable valid-jsdoc */
32    /**
33     * Get the spline segment from a given point's previous neighbour to the
34     * given point.
35     *
36     * @private
37     * @function Highcharts.seriesTypes.spline#getPointSpline
38     */
39    getPointSpline(points, point, i) {
40        const 
41        // 1 means control points midway between points, 2 means 1/3
42        // from the point, 3 is 1/4 etc
43        smoothing = 1.5, denom = smoothing + 1, plotX = point.plotX || 0, plotY = point.plotY || 0, lastPoint = points[i - 1], nextPoint = points[i + 1];
44        let leftContX, leftContY, rightContX, rightContY;
45        /**
46         * @private
47         */
48        function doCurve(otherPoint) {
49            return otherPoint &&
50                !otherPoint.isNull &&
51                otherPoint.doCurve !== false &&
52                // #6387, area splines next to null:
53                !point.isCliff;
54        }
55        // Find control points
56        if (doCurve(lastPoint) && doCurve(nextPoint)) {
57            const lastX = lastPoint.plotX || 0, lastY = lastPoint.plotY || 0, nextX = nextPoint.plotX || 0, nextY = nextPoint.plotY || 0;
58            let correction = 0;
59            leftContX = (smoothing * plotX + lastX) / denom;
60            leftContY = (smoothing * plotY + lastY) / denom;
61            rightContX = (smoothing * plotX + nextX) / denom;
62            rightContY = (smoothing * plotY + nextY) / denom;
63            // Have the two control points make a straight line through main
64            // point
65            if (rightContX !== leftContX) { // #5016, division by zero
66                correction = (((rightContY - leftContY) *
67                    (rightContX - plotX)) /
68                    (rightContX - leftContX) + plotY - rightContY);
69            }
70            leftContY += correction;
71            rightContY += correction;
72            // To prevent false extremes, check that control points are
73            // between neighbouring points' y values
74            if (leftContY > lastY && leftContY > plotY) {
75                leftContY = Math.max(lastY, plotY);
76                // Mirror of left control point
77                rightContY = 2 * plotY - leftContY;
78            }
79            else if (leftContY < lastY && leftContY < plotY) {
80                leftContY = Math.min(lastY, plotY);
81                rightContY = 2 * plotY - leftContY;
82            }
83            if (rightContY > nextY && rightContY > plotY) {
84                rightContY = Math.max(nextY, plotY);
85                leftContY = 2 * plotY - rightContY;
86            }
87            else if (rightContY < nextY && rightContY < plotY) {
88                rightContY = Math.min(nextY, plotY);
89                leftContY = 2 * plotY - rightContY;
90            }
91            // Record for drawing in next point
92            point.rightContX = rightContX;
93            point.rightContY = rightContY;
94            // Visualize control points for debugging
95            /*
96            if (leftContX) {
97                this.chart.renderer
98                    .circle(
99                        leftContX + this.chart.plotLeft,
100                        leftContY + this.chart.plotTop,
101                        2
102                    )
103                    .attr({
104                        stroke: 'red',
105                        'stroke-width': 2,
106                        fill: 'none',
107                        zIndex: 9
108                    })
109                    .add();
110                this.chart.renderer
111                    .path([['M', leftContX + this.chart.plotLeft,
112                        leftContY + this.chart.plotTop
113                    ], ['L', plotX + this.chart.plotLeft,
114                        plotY + this.chart.plotTop
115                    ]])
116                    .attr({
117                        stroke: 'red',
118                        'stroke-width': 2,
119                        zIndex: 9
120                    })
121                    .add();
122            }
123            if (rightContX) {
124                this.chart.renderer
125                    .circle(
126                        rightContX + this.chart.plotLeft,
127                        rightContY + this.chart.plotTop,
128                        2
129                    )
130                    .attr({
131                        stroke: 'green',
132                        'stroke-width': 2,
133                        fill: 'none',
134                        zIndex: 9
135                    })
136                    .add();
137                this.chart.renderer
138                    .path([[
139                        'M', rightContX + this.chart.plotLeft,
140                        rightContY + this.chart.plotTop
141                    ], [
142                        'L', plotX + this.chart.plotLeft,
143                        plotY + this.chart.plotTop
144                    ]])
145                    .attr({
146                        stroke: 'green',
147                        'stroke-width': 2,
148                        zIndex: 9
149                    })
150                    .add();
151            }
152            // */
153            point.controlPoints = {
154                low: [leftContX, leftContY],
155                high: [rightContX, rightContY]
156            };
157        }
158        const ret = [
159            'C',
160            pick(lastPoint.rightContX, lastPoint.plotX, 0),
161            pick(lastPoint.rightContY, lastPoint.plotY, 0),
162            pick(leftContX, plotX, 0),
163            pick(leftContY, plotY, 0),
164            plotX,
165            plotY
166        ];
167        // Reset for updating series later
168        lastPoint.rightContX = lastPoint.rightContY = void 0;
169        return ret;
170    }
171}
172/* *
173 *
174 *  Static Properties
175 *
176 * */
177/**
178 * A spline series is a special type of line series, where the segments
179 * between the data points are smoothed.
180 *
181 * @sample {highcharts} highcharts/demo/spline-irregular-time/
182 *         Spline chart
183 * @sample {highstock} stock/demo/spline/
184 *         Spline chart
185 *
186 * @extends      plotOptions.series
187 * @excluding    step, boostThreshold, boostBlending
188 * @product      highcharts highstock
189 * @optionparent plotOptions.spline
190 */
191SplineSeries.defaultOptions = merge(LineSeries.defaultOptions);
192SeriesRegistry.registerSeriesType('spline', SplineSeries);
193/* *
194 *
195 *  Default Export
196 *
197 * */
198export default SplineSeries;
199/* *
200 *
201 *  API Options
202 *
203 * */
204/**
205 * A `spline` series. If the [type](#series.spline.type) option is
206 * not specified, it is inherited from [chart.type](#chart.type).
207 *
208 * @extends   series,plotOptions.spline
209 * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
210 * @product   highcharts highstock
211 * @apioption series.spline
212 */
213/**
214 * An array of data points for the series. For the `spline` series type,
215 * points can be given in the following ways:
216 *
217 * 1. An array of numerical values. In this case, the numerical values will be
218 *    interpreted as `y` options. The `x` values will be automatically
219 *    calculated, either starting at 0 and incremented by 1, or from
220 *    `pointStart` and `pointInterval` given in the series options. If the axis
221 *    has categories, these will be used. Example:
222 *    ```js
223 *    data: [0, 5, 3, 5]
224 *    ```
225 *
226 * 2. An array of arrays with 2 values. In this case, the values correspond to
227 *    `x,y`. If the first value is a string, it is applied as the name of the
228 *    point, and the `x` value is inferred.
229 *    ```js
230 *    data: [
231 *        [0, 9],
232 *        [1, 2],
233 *        [2, 8]
234 *    ]
235 *    ```
236 *
237 * 3. An array of objects with named values. The following snippet shows only a
238 *    few settings, see the complete options set below. If the total number of
239 *    data points exceeds the series'
240 *    [turboThreshold](#series.spline.turboThreshold),
241 *    this option is not available.
242 *    ```js
243 *    data: [{
244 *        x: 1,
245 *        y: 9,
246 *        name: "Point2",
247 *        color: "#00FF00"
248 *    }, {
249 *        x: 1,
250 *        y: 0,
251 *        name: "Point1",
252 *        color: "#FF00FF"
253 *    }]
254 *    ```
255 *
256 * @sample {highcharts} highcharts/chart/reflow-true/
257 *         Numerical values
258 * @sample {highcharts} highcharts/series/data-array-of-arrays/
259 *         Arrays of numeric x and y
260 * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
261 *         Arrays of datetime x and y
262 * @sample {highcharts} highcharts/series/data-array-of-name-value/
263 *         Arrays of point.name and y
264 * @sample {highcharts} highcharts/series/data-array-of-objects/
265 *         Config objects
266 *
267 * @type      {Array<number|Array<(number|string),(number|null)>|null|*>}
268 * @extends   series.line.data
269 * @product   highcharts highstock
270 * @apioption series.spline.data
271 */
272''; // Adds doclets above intro transpiled

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.