vector.src.js 14 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404
/**
 * @license Highcharts JS v7.2.0 (2019-09-03)
 *
 * Vector plot series module
 *
 * (c) 2010-2019 Torstein Honsi
 *
 * License: www.highcharts.com/license
 */
'use strict';
(function (factory) {
    if (typeof module === 'object' && module.exports) {
        factory['default'] = factory;
        module.exports = factory;
    } else if (typeof define === 'function' && define.amd) {
        define('highcharts/modules/vector', ['highcharts'], function (Highcharts) {
            factory(Highcharts);
            factory.Highcharts = Highcharts;
            return factory;
        });
    } else {
        factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
    }
}(function (Highcharts) {
    var _modules = Highcharts ? Highcharts._modules : {};
    function _registerModule(obj, path, args, fn) {
        if (!obj.hasOwnProperty(path)) {
            obj[path] = fn.apply(null, args);
        }
    }
    _registerModule(_modules, 'modules/vector.src.js', [_modules['parts/Globals.js']], function (H) {
        /* *
         * Vector plot series module
         *
         * (c) 2010-2019 Torstein Honsi
         *
         * License: www.highcharts.com/license
         */



        var seriesType = H.seriesType,
            pick = H.pick;

        /**
         * The vector series class.
         *
         * @private
         * @class
         * @name Highcharts.seriesTypes.vector
         *
         * @augments Highcharts.seriesTypes.scatter
         */
        seriesType('vector', 'scatter'

            /**
             * A vector plot is a type of cartesian chart where each point has an X and
             * Y position, a length and a direction. Vectors are drawn as arrows.
             *
             * @sample {highcharts|highstock} highcharts/demo/vector-plot/
             *         Vector pot
             *
             * @since        6.0.0
             * @extends      plotOptions.scatter
             * @excluding    boostThreshold, marker, connectEnds, connectNulls,
             *               cropThreshold, dashStyle, dragDrop, gapSize, gapUnit,
             *               dataGrouping, linecap, shadow, stacking, step, jitter
             * @product      highcharts highstock
             * @optionparent plotOptions.vector
             */
            , {

                /**
                 * The line width for each vector arrow.
                 */
                lineWidth: 2,

                /**
                 * @ignore
                 */
                marker: null,

                /**
                 * What part of the vector it should be rotated around. Can be one of
                 * `start`, `center` and `end`. When `start`, the vectors will start
                 * from the given [x, y] position, and when `end` the vectors will end
                 * in the [x, y] position.
                 *
                 * @sample highcharts/plotoptions/vector-rotationorigin-start/
                 *         Rotate from start
                 *
                 * @validvalue ["start", "center", "end"]
                 */
                rotationOrigin: 'center',

                states: {

                    hover: {

                        /**
                         * Additonal line width for the vector errors when they are
                         * hovered.
                         */
                        lineWidthPlus: 1
                    }
                },

                tooltip: {

                    /**
                     * @default [{point.x}, {point.y}] Length: {point.length} Direction: {point.direction}°
                     */
                    pointFormat: '<b>[{point.x}, {point.y}]</b><br/>Length: <b>{point.length}</b><br/>Direction: <b>{point.direction}\u00B0</b><br/>'
                },

                /**
                 * Maximum length of the arrows in the vector plot. The individual arrow
                 * length is computed between 0 and this value.
                 */
                vectorLength: 20

            }, {

                pointArrayMap: ['y', 'length', 'direction'],
                parallelArrays: ['x', 'y', 'length', 'direction'],

                /**
                 * Get presentational attributes.
                 *
                 * @private
                 * @function Highcharts.seriesTypes.vector#pointAttribs
                 *
                 * @param {Highcharts.Point} point
                 *
                 * @param {string} state
                 *
                 * @return {*}
                 */
                pointAttribs: function (point, state) {
                    var options = this.options,
                        stroke = point.color || this.color,
                        strokeWidth = this.options.lineWidth;

                    if (state) {
                        stroke = options.states[state].color || stroke;
                        strokeWidth =
                        (options.states[state].lineWidth || strokeWidth) +
                        (options.states[state].lineWidthPlus || 0);
                    }

                    return {
                        'stroke': stroke,
                        'stroke-width': strokeWidth
                    };
                },

                /**
                 * @ignore
                 * @deprecated
                 * @function Highcharts.seriesTypes.vector#markerAttribs
                 */
                markerAttribs: H.noop,

                /**
                 * @ignore
                 * @deprecated
                 * @function Highcharts.seriesTypes.vector#getSymbol
                 */
                getSymbol: H.noop,

                /**
                 * Create a single arrow. It is later rotated around the zero
                 * centerpoint.
                 *
                 * @private
                 * @function Highcharts.seriesTypes.vector#arrow
                 *
                 * @param {Highcharts.Point} point
                 *
                 * @return {Highcharts.SVGPathArray}
                 */
                arrow: function (point) {
                    var path,
                        fraction = point.length / this.lengthMax,
                        u = fraction * this.options.vectorLength / 20,
                        o = {
                            start: 10 * u,
                            center: 0,
                            end: -10 * u
                        }[this.options.rotationOrigin] || 0;

                    // The stem and the arrow head. Draw the arrow first with rotation
                    // 0, which is the arrow pointing down (vector from north to south).
                    path = [
                        'M', 0, 7 * u + o, // base of arrow
                        'L', -1.5 * u, 7 * u + o,
                        0, 10 * u + o,
                        1.5 * u, 7 * u + o,
                        0, 7 * u + o,
                        0, -10 * u + o// top
                    ];

                    return path;
                },

                /**
                 * @private
                 * @function Highcharts.seriesTypes.vector#translate
                 */
                translate: function () {
                    H.Series.prototype.translate.call(this);

                    this.lengthMax = H.arrayMax(this.lengthData);
                },

                /**
                 * @private
                 * @function Highcharts.seriesTypes.vector#drawPoints
                 */
                drawPoints: function () {

                    var chart = this.chart;

                    this.points.forEach(function (point) {
                        var plotX = point.plotX,
                            plotY = point.plotY;

                        if (
                            this.options.clip === false ||
                            chart.isInsidePlot(plotX, plotY, chart.inverted)
                        ) {

                            if (!point.graphic) {
                                point.graphic = this.chart.renderer
                                    .path()
                                    .add(this.markerGroup)
                                    .addClass(
                                        'highcharts-point ' +
                                        'highcharts-color-' +
                                        pick(point.colorIndex, point.series.colorIndex)
                                    );
                            }
                            point.graphic
                                .attr({
                                    d: this.arrow(point),
                                    translateX: plotX,
                                    translateY: plotY,
                                    rotation: point.direction
                                });

                            if (!this.chart.styledMode) {
                                point.graphic
                                    .attr(this.pointAttribs(point));
                            }

                        } else if (point.graphic) {
                            point.graphic = point.graphic.destroy();
                        }

                    }, this);
                },

                /**
                 * @ignore
                 * @deprecated
                 * @function Highcharts.seriesTypes.vector#drawGraph
                 */
                drawGraph: H.noop,

                /*
                drawLegendSymbol: function (legend, item) {
                    var options = legend.options,
                        symbolHeight = legend.symbolHeight,
                        square = options.squareSymbol,
                        symbolWidth = square ? symbolHeight : legend.symbolWidth,
                        path = this.arrow.call({
                            lengthMax: 1,
                            options: {
                                vectorLength: symbolWidth
                            }
                        }, {
                            length: 1
                        });

                    item.legendLine = this.chart.renderer.path(path)
                    .addClass('highcharts-point')
                    .attr({
                        zIndex: 3,
                        translateY: symbolWidth / 2,
                        rotation: 270,
                        'stroke-width': 1,
                        'stroke': 'black'
                    }).add(item.legendGroup);

                },
                */

                /**
                 * Fade in the arrows on initializing series.
                 *
                 * @private
                 * @function Highcharts.seriesTypes.vector#animate
                 *
                 * @param {boolean} [init]
                 */
                animate: function (init) {
                    if (init) {
                        this.markerGroup.attr({
                            opacity: 0.01
                        });
                    } else {
                        this.markerGroup.animate({
                            opacity: 1
                        }, H.animObject(this.options.animation));

                        this.animate = null;
                    }
                }
            });


        /**
         * A `vector` series. If the [type](#series.vector.type) option is not
         * specified, it is inherited from [chart.type](#chart.type).
         *
         * @extends   series,plotOptions.vector
         * @excluding dataParser, dataURL
         * @product   highcharts highstock
         * @apioption series.vector
         */

        /**
         * An array of data points for the series. For the `vector` series type,
         * points can be given in the following ways:
         *
         * 1. An array of arrays with 4 values. In this case, the values correspond to
         *    to `x,y,length,direction`. If the first value is a string, it is applied
         *    as the name of the point, and the `x` value is inferred.
         *    ```js
         *    data: [
         *        [0, 0, 10, 90],
         *        [0, 1, 5, 180],
         *        [1, 1, 2, 270]
         *    ]
         *    ```
         *
         * 2. An array of objects with named values. The following snippet shows only a
         *    few settings, see the complete options set below. If the total number of
         *    data points exceeds the series'
         *    [turboThreshold](#series.area.turboThreshold), this option is not
         *    available.
         *    ```js
         *    data: [{
         *        x: 0,
         *        y: 0,
         *        name: "Point2",
         *        length: 10,
         *        direction: 90
         *    }, {
         *        x: 1,
         *        y: 1,
         *        name: "Point1",
         *        direction: 270
         *    }]
         *    ```
         *
         * @sample {highcharts} highcharts/series/data-array-of-arrays/
         *         Arrays of numeric x and y
         * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
         *         Arrays of datetime x and y
         * @sample {highcharts} highcharts/series/data-array-of-name-value/
         *         Arrays of point.name and y
         * @sample {highcharts} highcharts/series/data-array-of-objects/
         *         Config objects
         *
         * @type      {Array<Array<(number|string),number,number,number>|*>}
         * @extends   series.line.data
         * @product   highcharts highstock
         * @apioption series.vector.data
         */

        /**
         * The length of the vector. The rendered length will relate to the
         * `vectorLength` setting.
         *
         * @type      {number}
         * @product   highcharts highstock
         * @apioption series.vector.data.length
         */

        /**
         * The vector direction in degrees, where 0 is north (pointing towards south).
         *
         * @type      {number}
         * @product   highcharts highstock
         * @apioption series.vector.data.direction
         */

    });
    _registerModule(_modules, 'masters/modules/vector.src.js', [], function () {


    });
}));