PageSourceSearch

https://www.saintlary.com/app/dist/saintlary-tourisme/addons/woody…/Axis/PlotLineOrBand/PlotLineOrBandAxis.js

js saintlary.com collected 2026-10-02 10:34:25 UTC 8,870 bytes, 262 lines download raw bytes

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 U from '../../Utilities.js';
12const { erase, extend, isNumber } = U;
13/* *
14 *
15 *  Composition
16 *
17 * */
18var PlotLineOrBandAxis;
19(function (PlotLineOrBandAxis) {
20    /* *
21     *
22     *  Declarations
23     *
24     * */
25    /* *
26     *
27     *  Variables
28     *
29     * */
30    let PlotLineOrBandClass;
31    /* *
32     *
33     *  Functions
34     *
35     * */
36    /**
37     * Add a plot band after render time.
38     *
39     * @sample highcharts/members/axis-addplotband/
40     *         Toggle the plot band from a button
41     *
42     * @function Highcharts.Axis#addPlotBand
43     *
44     * @param {Highcharts.AxisPlotBandsOptions} options
45     * A configuration object for the plot band, as defined in
46     * [xAxis.plotBands](https://api.highcharts.com/highcharts/xAxis.plotBands).
47     *
48     * @return {Highcharts.PlotLineOrBand|undefined}
49     * The added plot band, or `undefined` if the options are not valid.
50     */
51    function addPlotBand(options) {
52        return this.addPlotBandOrLine(options, 'plotBands');
53    }
54    /**
55     * Add a plot band or plot line after render time. Called from
56     * addPlotBand and addPlotLine internally.
57     *
58     * @private
59     * @function Highcharts.Axis#addPlotBandOrLine
60     * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
61     * The plotBand or plotLine configuration object.
62     */
63    function addPlotBandOrLine(options, coll) {
64        const userOptions = this.userOptions;
65        let obj = new PlotLineOrBandClass(this, options);
66        if (this.visible) {
67            obj = obj.render();
68        }
69        if (obj) { // #2189
70            if (!this._addedPlotLB) {
71                this._addedPlotLB = true;
72                (userOptions.plotLines || [])
73                    .concat(userOptions.plotBands || [])
74                    .forEach((plotLineOptions) => {
75                    this.addPlotBandOrLine(plotLineOptions);
76                });
77            }
78            // Add it to the user options for exporting and Axis.update
79            if (coll) {
80                // Workaround Microsoft/TypeScript issue #32693
81                const updatedOptions = (userOptions[coll] || []);
82                updatedOptions.push(options);
83                userOptions[coll] = updatedOptions;
84            }
85            this.plotLinesAndBands.push(obj);
86        }
87        return obj;
88    }
89    /**
90     * Add a plot line after render time.
91     *
92     * @sample highcharts/members/axis-addplotline/
93     *         Toggle the plot line from a button
94     *
95     * @function Highcharts.Axis#addPlotLine
96     *
97     * @param {Highcharts.AxisPlotLinesOptions} options
98     * A configuration object for the plot line, as defined in
99     * [xAxis.plotLines](https://api.highcharts.com/highcharts/xAxis.plotLines).
100     *
101     * @return {Highcharts.PlotLineOrBand|undefined}
102     * The added plot line, or `undefined` if the options are not valid.
103     */
104    function addPlotLine(options) {
105        return this.addPlotBandOrLine(options, 'plotLines');
106    }
107    /**
108     * @private
109     */
110    function compose(PlotLineOrBandType, AxisClass) {
111        const axisProto = AxisClass.prototype;
112        if (!axisProto.addPlotBand) {
113            PlotLineOrBandClass = PlotLineOrBandType;
114            extend(axisProto, {
115                addPlotBand,
116                addPlotLine,
117                addPlotBandOrLine,
118                getPlotBandPath,
119                removePlotBand,
120                removePlotLine,
121                removePlotBandOrLine
122            });
123        }
124        return AxisClass;
125    }
126    PlotLineOrBandAxis.compose = compose;
127    /**
128     * Internal function to create the SVG path definition for a plot band.
129     *
130     * @function Highcharts.Axis#getPlotBandPath
131     *
132     * @param {number} from
133     * The axis value to start from.
134     *
135     * @param {number} to
136     * The axis value to end on.
137     *
138     * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
139     * The plotBand or plotLine configuration object.
140     *
141     * @return {Highcharts.SVGPathArray}
142     * The SVG path definition in array form.
143     */
144    function getPlotBandPath(from, to, options) {
145        options = options || this.options;
146        const toPath = this.getPlotLinePath({
147            value: to,
148            force: true,
149            acrossPanes: options.acrossPanes
150        }), result = [], horiz = this.horiz, outside = !isNumber(this.min) ||
151            !isNumber(this.max) ||
152            (from < this.min && to < this.min) ||
153            (from > this.max && to > this.max), path = this.getPlotLinePath({
154            value: from,
155            force: true,
156            acrossPanes: options.acrossPanes
157        });
158        let i, 
159        // #4964 check if chart is inverted or plotband is on yAxis
160        plus = 1, isFlat;
161        if (path && toPath) {
162            // Flat paths don't need labels (#3836)
163            if (outside) {
164                isFlat = path.toString() === toPath.toString();
165                plus = 0;
166            }
167            // Go over each subpath - for panes in Highcharts Stock
168            for (i = 0; i < path.length; i += 2) {
169                const pathStart = path[i], pathEnd = path[i + 1], toPathStart = toPath[i], toPathEnd = toPath[i + 1];
170                // Type checking all affected path segments. Consider
171                // something smarter.
172                if ((pathStart[0] === 'M' || pathStart[0] === 'L') &&
173                    (pathEnd[0] === 'M' || pathEnd[0] === 'L') &&
174                    (toPathStart[0] === 'M' || toPathStart[0] === 'L') &&
175                    (toPathEnd[0] === 'M' || toPathEnd[0] === 'L')) {
176                    // Add 1 pixel when coordinates are the same
177                    if (horiz && toPathStart[1] === pathStart[1]) {
178                        toPathStart[1] += plus;
179                        toPathEnd[1] += plus;
180                    }
181                    else if (!horiz && toPathStart[2] === pathStart[2]) {
182                        toPathStart[2] += plus;
183                        toPathEnd[2] += plus;
184                    }
185                    result.push(['M', pathStart[1], pathStart[2]], ['L', pathEnd[1], pathEnd[2]], ['L', toPathEnd[1], toPathEnd[2]], ['L', toPathStart[1], toPathStart[2]], ['Z']);
186                }
187                result.isFlat = isFlat;
188            }
189        }
190        return result;
191    }
192    /**
193     * Remove a plot band by its id.
194     *
195     * @sample highcharts/members/axis-removeplotband/
196     *         Remove plot band by id
197     * @sample highcharts/members/axis-addplotband/
198     *         Toggle the plot band from a button
199     *
200     * @function Highcharts.Axis#removePlotBand
201     *
202     * @param {string} id
203     *        The plot band's `id` as given in the original configuration
204     *        object or in the `addPlotBand` option.
205     */
206    function removePlotBand(id) {
207        this.removePlotBandOrLine(id);
208    }
209    /**
210     * Remove a plot band or plot line from the chart by id. Called
211     * internally from `removePlotBand` and `removePlotLine`.
212     * @private
213     * @function Highcharts.Axis#removePlotBandOrLine
214     */
215    function removePlotBandOrLine(id) {
216        const plotLinesAndBands = this.plotLinesAndBands, options = this.options, userOptions = this.userOptions;
217        if (plotLinesAndBands) { // #15639
218            let i = plotLinesAndBands.length;
219            while (i--) {
220                if (plotLinesAndBands[i].id === id) {
221                    plotLinesAndBands[i].destroy();
222                }
223            }
224            ([
225                options.plotLines || [],
226                userOptions.plotLines || [],
227                options.plotBands || [],
228                userOptions.plotBands || []
229            ]).forEach(function (arr) {
230                i = arr.length;
231                while (i--) {
232                    if ((arr[i] || {}).id === id) {
233                        erase(arr, arr[i]);
234                    }
235                }
236            });
237        }
238    }
239    /**
240     * Remove a plot line by its id.
241     *
242     * @sample highcharts/xaxis/plotlines-id/
243     *         Remove plot line by id
244     * @sample highcharts/members/axis-addplotline/
245     *         Toggle the plot line from a button
246     *
247     * @function Highcharts.Axis#removePlotLine
248     *
249     * @param {string} id
250     *        The plot line's `id` as given in the original configuration
251     *        object or in the `addPlotLine` option.
252     */
253    function removePlotLine(id) {
254        this.removePlotBandOrLine(id);
255    }
256})(PlotLineOrBandAxis || (PlotLineOrBandAxis = {}));
257/* *
258 *
259 *  Default Export
260 *
261 * */
262export default PlotLineOrBandAxis;

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.