123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327 |
- /**
- * @license Highcharts JS v7.0.2 (2019-01-17)
- *
- * Pareto series type for Highcharts
- *
- * (c) 2010-2019 Sebastian Bochan
- *
- * 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(function () {
- return factory;
- });
- } else {
- factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
- }
- }(function (Highcharts) {
- var derivedSeriesMixin = (function (H) {
- var Series = H.Series,
- addEvent = H.addEvent,
- noop = H.noop;
- /* ************************************************************************** *
- *
- * DERIVED SERIES MIXIN
- *
- * ************************************************************************** */
- /**
- * Provides methods for auto setting/updating series data based on the based
- * series data.
- *
- * @private
- * @mixin derivedSeriesMixin
- */
- var derivedSeriesMixin = {
- /**
- * Initialise series
- *
- * @private
- * @function derivedSeriesMixin.init
- */
- init: function () {
- Series.prototype.init.apply(this, arguments);
- this.initialised = false;
- this.baseSeries = null;
- this.eventRemovers = [];
- this.addEvents();
- },
- /**
- * Method to be implemented - inside the method the series has already
- * access to the base series via m `this.baseSeries` and the bases data is
- * initialised. It should return data in the format accepted by
- * `Series.setData()` method
- *
- * @private
- * @function derivedSeriesMixin.setDerivedData
- *
- * @return {Array<*>}
- * An array of data
- */
- setDerivedData: noop,
- /**
- * Sets base series for the series
- *
- * @private
- * @function derivedSeriesMixin.setBaseSeries
- */
- setBaseSeries: function () {
- var chart = this.chart,
- baseSeriesOptions = this.options.baseSeries,
- baseSeries =
- baseSeriesOptions &&
- (chart.series[baseSeriesOptions] || chart.get(baseSeriesOptions));
- this.baseSeries = baseSeries || null;
- },
- /**
- * Adds events for the series
- *
- * @private
- * @function derivedSeriesMixin.addEvents
- */
- addEvents: function () {
- var derivedSeries = this,
- chartSeriesLinked;
- chartSeriesLinked = addEvent(
- this.chart,
- 'afterLinkSeries',
- function () {
- derivedSeries.setBaseSeries();
- if (derivedSeries.baseSeries && !derivedSeries.initialised) {
- derivedSeries.setDerivedData();
- derivedSeries.addBaseSeriesEvents();
- derivedSeries.initialised = true;
- }
- }
- );
- this.eventRemovers.push(
- chartSeriesLinked
- );
- },
- /**
- * Adds events to the base series - it required for recalculating the data
- * in the series if the base series is updated / removed / etc.
- *
- * @private
- * @function derivedSeriesMixin.addBaseSeriesEvents
- */
- addBaseSeriesEvents: function () {
- var derivedSeries = this,
- updatedDataRemover,
- destroyRemover;
- updatedDataRemover = addEvent(
- derivedSeries.baseSeries,
- 'updatedData',
- function () {
- derivedSeries.setDerivedData();
- }
- );
- destroyRemover = addEvent(
- derivedSeries.baseSeries,
- 'destroy',
- function () {
- derivedSeries.baseSeries = null;
- derivedSeries.initialised = false;
- }
- );
- derivedSeries.eventRemovers.push(
- updatedDataRemover,
- destroyRemover
- );
- },
- /**
- * Destroys the series
- *
- * @private
- * @function derivedSeriesMixin.destroy
- */
- destroy: function () {
- this.eventRemovers.forEach(function (remover) {
- remover();
- });
- Series.prototype.destroy.apply(this, arguments);
- }
- };
- return derivedSeriesMixin;
- }(Highcharts));
- (function (H, derivedSeriesMixin) {
- /* *
- * (c) 2010-2017 Sebastian Bochan
- *
- * License: www.highcharts.com/license
- */
- var correctFloat = H.correctFloat,
- seriesType = H.seriesType,
- merge = H.merge;
- /**
- * The pareto series type.
- *
- * @private
- * @class
- * @name Highcharts.seriesTypes.pareto
- *
- * @augments Highcharts.Series
- */
- seriesType('pareto', 'line'
- /**
- * A pareto diagram is a type of chart that contains both bars and a line graph,
- * where individual values are represented in descending order by bars, and the
- * cumulative total is represented by the line.
- *
- * @sample {highcharts} highcharts/demo/pareto/
- * Pareto diagram
- *
- * @extends plotOptions.line
- * @since 6.0.0
- * @product highcharts
- * @excluding allAreas, boostThreshold, borderColor, borderRadius,
- * borderWidth, crisp, colorAxis, depth, data, edgeColor,
- * edgeWidth, findNearestPointBy, gapSize, gapUnit, grouping,
- * groupPadding, groupZPadding, maxPointWidth, keys,
- * negativeColor, pointInterval, pointIntervalUnit, pointPadding,
- * pointPlacement, pointRange, pointStart, pointWidth, shadow,
- * step, softThreshold, stacking, threshold, zoneAxis, zones
- * @optionparent plotOptions.pareto
- */
- , {
- /**
- * Higher zIndex than column series to draw line above shapes.
- */
- zIndex: 3
- }, merge(derivedSeriesMixin, {
- /**
- * Calculate sum and return percent points.
- *
- * @private
- * @function Highcharts.Series#setDerivedData
- *
- * @return {Array<Array<number,number>>}
- * Returns array of points [x,y]
- */
- setDerivedData: function () {
- if (this.baseSeries.yData.length > 1) {
- var xValues = this.baseSeries.xData,
- yValues = this.baseSeries.yData,
- sum = this.sumPointsPercents(yValues, xValues, null, true);
- this.setData(
- this.sumPointsPercents(yValues, xValues, sum, false),
- false
- );
- }
- },
- /**
- * Calculate y sum and each percent point.
- *
- * @private
- * @function Highcharts.Series#sumPointsPercents
- *
- * @param {Array<number>} yValues
- * Y values
- *
- * @param {Array<number>} xValues
- * X values
- *
- * @param {number} sum
- * Sum of all y values
- *
- * @param {boolean} [isSum]
- * Declares if calculate sum of all points
- *
- * @return {number|Array<number,number>}
- * Returns sum of points or array of points [x,sum]
- */
- sumPointsPercents: function (yValues, xValues, sum, isSum) {
- var sumY = 0,
- sumPercent = 0,
- percentPoints = [],
- percentPoint;
- yValues.forEach(function (point, i) {
- if (point !== null) {
- if (isSum) {
- sumY += point;
- } else {
- percentPoint = (point / sum) * 100;
- percentPoints.push([
- xValues[i],
- correctFloat(sumPercent + percentPoint)
- ]);
- sumPercent += percentPoint;
- }
- }
- });
- return isSum ? sumY : percentPoints;
- }
- }));
- /**
- * A `pareto` series. If the [type](#series.pareto.type) option is not
- * specified, it is inherited from [chart.type](#chart.type).
- *
- * @extends series,plotOptions.pareto
- * @since 6.0.0
- * @product highcharts
- * @excluding data, dataParser, dataURL
- * @apioption series.pareto
- */
- /**
- * An integer identifying the index to use for the base series, or a string
- * representing the id of the series.
- *
- * @type {number|string}
- * @default undefined
- * @apioption series.pareto.baseSeries
- */
- /**
- * An array of data points for the series. For the `pareto` series type,
- * points are calculated dynamically.
- *
- * @type {Array<Array<number|string>|*>}
- * @extends series.column.data
- * @since 6.0.0
- * @product highcharts
- * @apioption series.pareto.data
- */
- }(Highcharts, derivedSeriesMixin));
- return (function () {
- }());
- }));
|