chore: version inicial del codigo fuente del LMS Estafeta
This commit is contained in:
@@ -0,0 +1,415 @@
|
||||
/* *
|
||||
*
|
||||
* (c) 2010-2020 Torstein Honsi
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*
|
||||
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
|
||||
*
|
||||
* */
|
||||
'use strict';
|
||||
import Chart from '../Core/Chart/Chart.js';
|
||||
import H from '../Core/Globals.js';
|
||||
import O from '../Core/Options.js';
|
||||
var defaultOptions = O.defaultOptions;
|
||||
import SVGRenderer from '../Core/Renderer/SVG/SVGRenderer.js';
|
||||
import U from '../Core/Utilities.js';
|
||||
var extend = U.extend, getOptions = U.getOptions, merge = U.merge, pick = U.pick;
|
||||
import '../Core/Options.js';
|
||||
import '../Core/Chart/Chart.js';
|
||||
var Renderer = H.Renderer, VMLRenderer = H.VMLRenderer;
|
||||
// Add language
|
||||
extend(defaultOptions.lang, {
|
||||
zoomIn: 'Zoom in',
|
||||
zoomOut: 'Zoom out'
|
||||
});
|
||||
// Set the default map navigation options
|
||||
/**
|
||||
* @product highmaps
|
||||
* @optionparent mapNavigation
|
||||
*/
|
||||
defaultOptions.mapNavigation = {
|
||||
/**
|
||||
* General options for the map navigation buttons. Individual options
|
||||
* can be given from the [mapNavigation.buttons](#mapNavigation.buttons)
|
||||
* option set.
|
||||
*
|
||||
* @sample {highmaps} maps/mapnavigation/button-theme/
|
||||
* Theming the navigation buttons
|
||||
*/
|
||||
buttonOptions: {
|
||||
/**
|
||||
* What box to align the buttons to. Possible values are `plotBox`
|
||||
* and `spacingBox`.
|
||||
*
|
||||
* @type {Highcharts.ButtonRelativeToValue}
|
||||
*/
|
||||
alignTo: 'plotBox',
|
||||
/**
|
||||
* The alignment of the navigation buttons.
|
||||
*
|
||||
* @type {Highcharts.AlignValue}
|
||||
*/
|
||||
align: 'left',
|
||||
/**
|
||||
* The vertical alignment of the buttons. Individual alignment can
|
||||
* be adjusted by each button's `y` offset.
|
||||
*
|
||||
* @type {Highcharts.VerticalAlignValue}
|
||||
*/
|
||||
verticalAlign: 'top',
|
||||
/**
|
||||
* The X offset of the buttons relative to its `align` setting.
|
||||
*/
|
||||
x: 0,
|
||||
/**
|
||||
* The width of the map navigation buttons.
|
||||
*/
|
||||
width: 18,
|
||||
/**
|
||||
* The pixel height of the map navigation buttons.
|
||||
*/
|
||||
height: 18,
|
||||
/**
|
||||
* Padding for the navigation buttons.
|
||||
*
|
||||
* @since 5.0.0
|
||||
*/
|
||||
padding: 5,
|
||||
/**
|
||||
* Text styles for the map navigation buttons.
|
||||
*
|
||||
* @type {Highcharts.CSSObject}
|
||||
* @default {"fontSize": "15px", "fontWeight": "bold"}
|
||||
*/
|
||||
style: {
|
||||
/** @ignore */
|
||||
fontSize: '15px',
|
||||
/** @ignore */
|
||||
fontWeight: 'bold'
|
||||
},
|
||||
/**
|
||||
* A configuration object for the button theme. The object accepts
|
||||
* SVG properties like `stroke-width`, `stroke` and `fill`. Tri-state
|
||||
* button styles are supported by the `states.hover` and `states.select`
|
||||
* objects.
|
||||
*
|
||||
* @sample {highmaps} maps/mapnavigation/button-theme/
|
||||
* Themed navigation buttons
|
||||
*
|
||||
* @type {Highcharts.SVGAttributes}
|
||||
* @default {"stroke-width": 1, "text-align": "center"}
|
||||
*/
|
||||
theme: {
|
||||
/** @ignore */
|
||||
'stroke-width': 1,
|
||||
/** @ignore */
|
||||
'text-align': 'center'
|
||||
}
|
||||
},
|
||||
/**
|
||||
* The individual buttons for the map navigation. This usually includes
|
||||
* the zoom in and zoom out buttons. Properties for each button is
|
||||
* inherited from
|
||||
* [mapNavigation.buttonOptions](#mapNavigation.buttonOptions), while
|
||||
* individual options can be overridden. But default, the `onclick`, `text`
|
||||
* and `y` options are individual.
|
||||
*/
|
||||
buttons: {
|
||||
/**
|
||||
* Options for the zoom in button. Properties for the zoom in and zoom
|
||||
* out buttons are inherited from
|
||||
* [mapNavigation.buttonOptions](#mapNavigation.buttonOptions), while
|
||||
* individual options can be overridden. By default, the `onclick`,
|
||||
* `text` and `y` options are individual.
|
||||
*
|
||||
* @extends mapNavigation.buttonOptions
|
||||
*/
|
||||
zoomIn: {
|
||||
// eslint-disable-next-line valid-jsdoc
|
||||
/**
|
||||
* Click handler for the button.
|
||||
*
|
||||
* @type {Function}
|
||||
* @default function () { this.mapZoom(0.5); }
|
||||
*/
|
||||
onclick: function () {
|
||||
this.mapZoom(0.5);
|
||||
},
|
||||
/**
|
||||
* The text for the button. The tooltip (title) is a language option
|
||||
* given by [lang.zoomIn](#lang.zoomIn).
|
||||
*/
|
||||
text: '+',
|
||||
/**
|
||||
* The position of the zoomIn button relative to the vertical
|
||||
* alignment.
|
||||
*/
|
||||
y: 0
|
||||
},
|
||||
/**
|
||||
* Options for the zoom out button. Properties for the zoom in and
|
||||
* zoom out buttons are inherited from
|
||||
* [mapNavigation.buttonOptions](#mapNavigation.buttonOptions), while
|
||||
* individual options can be overridden. By default, the `onclick`,
|
||||
* `text` and `y` options are individual.
|
||||
*
|
||||
* @extends mapNavigation.buttonOptions
|
||||
*/
|
||||
zoomOut: {
|
||||
// eslint-disable-next-line valid-jsdoc
|
||||
/**
|
||||
* Click handler for the button.
|
||||
*
|
||||
* @type {Function}
|
||||
* @default function () { this.mapZoom(2); }
|
||||
*/
|
||||
onclick: function () {
|
||||
this.mapZoom(2);
|
||||
},
|
||||
/**
|
||||
* The text for the button. The tooltip (title) is a language option
|
||||
* given by [lang.zoomOut](#lang.zoomIn).
|
||||
*/
|
||||
text: '-',
|
||||
/**
|
||||
* The position of the zoomOut button relative to the vertical
|
||||
* alignment.
|
||||
*/
|
||||
y: 28
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Whether to enable navigation buttons. By default it inherits the
|
||||
* [enabled](#mapNavigation.enabled) setting.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @apioption mapNavigation.enableButtons
|
||||
*/
|
||||
/**
|
||||
* Whether to enable map navigation. The default is not to enable
|
||||
* navigation, as many choropleth maps are simple and don't need it.
|
||||
* Additionally, when touch zoom and mousewheel zoom is enabled, it breaks
|
||||
* the default behaviour of these interactions in the website, and the
|
||||
* implementer should be aware of this.
|
||||
*
|
||||
* Individual interactions can be enabled separately, namely buttons,
|
||||
* multitouch zoom, double click zoom, double click zoom to element and
|
||||
* mousewheel zoom.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
* @apioption mapNavigation.enabled
|
||||
*/
|
||||
/**
|
||||
* Enables zooming in on an area on double clicking in the map. By default
|
||||
* it inherits the [enabled](#mapNavigation.enabled) setting.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @apioption mapNavigation.enableDoubleClickZoom
|
||||
*/
|
||||
/**
|
||||
* Whether to zoom in on an area when that area is double clicked.
|
||||
*
|
||||
* @sample {highmaps} maps/mapnavigation/doubleclickzoomto/
|
||||
* Enable double click zoom to
|
||||
*
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
* @apioption mapNavigation.enableDoubleClickZoomTo
|
||||
*/
|
||||
/**
|
||||
* Enables zooming by mouse wheel. By default it inherits the [enabled](
|
||||
* #mapNavigation.enabled) setting.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @apioption mapNavigation.enableMouseWheelZoom
|
||||
*/
|
||||
/**
|
||||
* Whether to enable multitouch zooming. Note that if the chart covers the
|
||||
* viewport, this prevents the user from using multitouch and touchdrag on
|
||||
* the web page, so you should make sure the user is not trapped inside the
|
||||
* chart. By default it inherits the [enabled](#mapNavigation.enabled)
|
||||
* setting.
|
||||
*
|
||||
* @type {boolean}
|
||||
* @apioption mapNavigation.enableTouchZoom
|
||||
*/
|
||||
/**
|
||||
* Sensitivity of mouse wheel or trackpad scrolling. 1 is no sensitivity,
|
||||
* while with 2, one mousewheel delta will zoom in 50%.
|
||||
*
|
||||
* @since 4.2.4
|
||||
*/
|
||||
mouseWheelSensitivity: 1.1
|
||||
// enabled: false,
|
||||
// enableButtons: null, // inherit from enabled
|
||||
// enableTouchZoom: null, // inherit from enabled
|
||||
// enableDoubleClickZoom: null, // inherit from enabled
|
||||
// enableDoubleClickZoomTo: false
|
||||
// enableMouseWheelZoom: null, // inherit from enabled
|
||||
};
|
||||
/* eslint-disable valid-jsdoc */
|
||||
/**
|
||||
* Utility for reading SVG paths directly.
|
||||
*
|
||||
* @requires modules/map
|
||||
*
|
||||
* @function Highcharts.splitPath
|
||||
*
|
||||
* @param {string|Array<string|number>} path
|
||||
*
|
||||
* @return {Highcharts.SVGPathArray}
|
||||
*/
|
||||
H.splitPath = function (path) {
|
||||
var arr;
|
||||
if (typeof path === 'string') {
|
||||
path = path
|
||||
// Move letters apart
|
||||
.replace(/([A-Za-z])/g, ' $1 ')
|
||||
// Trim
|
||||
.replace(/^\s*/, '').replace(/\s*$/, '');
|
||||
// Split on spaces and commas. The semicolon is bogus, designed to
|
||||
// circumvent string replacement in the pre-v7 assembler that built
|
||||
// specific styled mode files.
|
||||
var split = path.split(/[ ,;]+/);
|
||||
arr = split.map(function (item) {
|
||||
if (!/[A-za-z]/.test(item)) {
|
||||
return parseFloat(item);
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
else {
|
||||
arr = path;
|
||||
}
|
||||
return SVGRenderer.prototype.pathToSegments(arr);
|
||||
};
|
||||
/**
|
||||
* Contains all loaded map data for Highmaps.
|
||||
*
|
||||
* @requires modules/map
|
||||
*
|
||||
* @name Highcharts.maps
|
||||
* @type {Highcharts.Dictionary<*>}
|
||||
*/
|
||||
H.maps = {};
|
||||
/**
|
||||
* Create symbols for the zoom buttons
|
||||
* @private
|
||||
*/
|
||||
function selectiveRoundedRect(x, y, w, h, rTopLeft, rTopRight, rBottomRight, rBottomLeft) {
|
||||
return [
|
||||
['M', x + rTopLeft, y],
|
||||
// top side
|
||||
['L', x + w - rTopRight, y],
|
||||
// top right corner
|
||||
['C', x + w - rTopRight / 2, y, x + w, y + rTopRight / 2, x + w, y + rTopRight],
|
||||
// right side
|
||||
['L', x + w, y + h - rBottomRight],
|
||||
// bottom right corner
|
||||
['C', x + w, y + h - rBottomRight / 2, x + w - rBottomRight / 2, y + h, x + w - rBottomRight, y + h],
|
||||
// bottom side
|
||||
['L', x + rBottomLeft, y + h],
|
||||
// bottom left corner
|
||||
['C', x + rBottomLeft / 2, y + h, x, y + h - rBottomLeft / 2, x, y + h - rBottomLeft],
|
||||
// left side
|
||||
['L', x, y + rTopLeft],
|
||||
// top left corner
|
||||
['C', x, y + rTopLeft / 2, x + rTopLeft / 2, y, x + rTopLeft, y],
|
||||
['Z']
|
||||
];
|
||||
}
|
||||
SVGRenderer.prototype.symbols.topbutton = function (x, y, w, h, options) {
|
||||
var r = (options && options.r) || 0;
|
||||
return selectiveRoundedRect(x - 1, y - 1, w, h, r, r, 0, 0);
|
||||
};
|
||||
SVGRenderer.prototype.symbols.bottombutton = function (x, y, w, h, options) {
|
||||
var r = (options && options.r) || 0;
|
||||
return selectiveRoundedRect(x - 1, y - 1, w, h, 0, 0, r, r);
|
||||
};
|
||||
// The symbol callbacks are generated on the SVGRenderer object in all browsers.
|
||||
// Even VML browsers need this in order to generate shapes in export. Now share
|
||||
// them with the VMLRenderer.
|
||||
if (Renderer === VMLRenderer) {
|
||||
['topbutton', 'bottombutton'].forEach(function (shape) {
|
||||
VMLRenderer.prototype.symbols[shape] =
|
||||
SVGRenderer.prototype.symbols[shape];
|
||||
});
|
||||
}
|
||||
/**
|
||||
* The factory function for creating new map charts. Creates a new {@link
|
||||
* Highcharts.Chart|Chart} object with different default options than the basic
|
||||
* Chart.
|
||||
*
|
||||
* @requires modules/map
|
||||
*
|
||||
* @function Highcharts.mapChart
|
||||
*
|
||||
* @param {string|Highcharts.HTMLDOMElement} [renderTo]
|
||||
* The DOM element to render to, or its id.
|
||||
*
|
||||
* @param {Highcharts.Options} options
|
||||
* The chart options structure as described in the
|
||||
* [options reference](https://api.highcharts.com/highstock).
|
||||
*
|
||||
* @param {Highcharts.ChartCallbackFunction} [callback]
|
||||
* A function to execute when the chart object is finished loading and
|
||||
* rendering. In most cases the chart is built in one thread, but in
|
||||
* Internet Explorer version 8 or less the chart is sometimes
|
||||
* initialized before the document is ready, and in these cases the
|
||||
* chart object will not be finished synchronously. As a consequence,
|
||||
* code that relies on the newly built Chart object should always run in
|
||||
* the callback. Defining a
|
||||
* [chart.events.load](https://api.highcharts.com/highstock/chart.events.load)
|
||||
* handler is equivalent.
|
||||
*
|
||||
* @return {Highcharts.Chart}
|
||||
* The chart object.
|
||||
*/
|
||||
H.Map = H.mapChart = function (a, b, c) {
|
||||
var hasRenderToArg = typeof a === 'string' || a.nodeName, options = arguments[hasRenderToArg ? 1 : 0], userOptions = options, hiddenAxis = {
|
||||
endOnTick: false,
|
||||
visible: false,
|
||||
minPadding: 0,
|
||||
maxPadding: 0,
|
||||
startOnTick: false
|
||||
}, seriesOptions, defaultCreditsOptions = getOptions().credits;
|
||||
/* For visual testing
|
||||
hiddenAxis.gridLineWidth = 1;
|
||||
hiddenAxis.gridZIndex = 10;
|
||||
hiddenAxis.tickPositions = undefined;
|
||||
// */
|
||||
// Don't merge the data
|
||||
seriesOptions = options.series;
|
||||
options.series = null;
|
||||
options = merge({
|
||||
chart: {
|
||||
panning: {
|
||||
enabled: true,
|
||||
type: 'xy'
|
||||
},
|
||||
type: 'map'
|
||||
},
|
||||
credits: {
|
||||
mapText: pick(defaultCreditsOptions.mapText, ' \u00a9 <a href="{geojson.copyrightUrl}">' +
|
||||
'{geojson.copyrightShort}</a>'),
|
||||
mapTextFull: pick(defaultCreditsOptions.mapTextFull, '{geojson.copyright}')
|
||||
},
|
||||
tooltip: {
|
||||
followTouchMove: false
|
||||
},
|
||||
xAxis: hiddenAxis,
|
||||
yAxis: merge(hiddenAxis, { reversed: true })
|
||||
}, options, // user's options
|
||||
{
|
||||
chart: {
|
||||
inverted: false,
|
||||
alignTicks: false
|
||||
}
|
||||
});
|
||||
options.series = userOptions.series = seriesOptions;
|
||||
return hasRenderToArg ?
|
||||
new Chart(a, options, c) :
|
||||
new Chart(options, b);
|
||||
};
|
||||
@@ -0,0 +1,301 @@
|
||||
/* *
|
||||
*
|
||||
* (c) 2010-2020 Torstein Honsi
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*
|
||||
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
|
||||
*
|
||||
* */
|
||||
'use strict';
|
||||
import Chart from '../Core/Chart/Chart.js';
|
||||
import H from '../Core/Globals.js';
|
||||
var doc = H.doc;
|
||||
import U from '../Core/Utilities.js';
|
||||
var addEvent = U.addEvent, extend = U.extend, merge = U.merge, objectEach = U.objectEach, pick = U.pick;
|
||||
/* eslint-disable no-invalid-this, valid-jsdoc */
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function stopEvent(e) {
|
||||
if (e) {
|
||||
if (e.preventDefault) {
|
||||
e.preventDefault();
|
||||
}
|
||||
if (e.stopPropagation) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
e.cancelBubble = true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The MapNavigation handles buttons for navigation in addition to mousewheel
|
||||
* and doubleclick handlers for chart zooming.
|
||||
*
|
||||
* @private
|
||||
* @class
|
||||
* @name MapNavigation
|
||||
*
|
||||
* @param {Highcharts.Chart} chart
|
||||
* The Chart instance.
|
||||
*/
|
||||
function MapNavigation(chart) {
|
||||
this.init(chart);
|
||||
}
|
||||
/**
|
||||
* Initialize function.
|
||||
*
|
||||
* @function MapNavigation#init
|
||||
*
|
||||
* @param {Highcharts.Chart} chart
|
||||
* The Chart instance.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
MapNavigation.prototype.init = function (chart) {
|
||||
this.chart = chart;
|
||||
chart.mapNavButtons = [];
|
||||
};
|
||||
/**
|
||||
* Update the map navigation with new options. Calling this is the same as
|
||||
* calling `chart.update({ mapNavigation: {} })`.
|
||||
*
|
||||
* @function MapNavigation#update
|
||||
*
|
||||
* @param {Highcharts.MapNavigationOptions} [options]
|
||||
* New options for the map navigation.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
MapNavigation.prototype.update = function (options) {
|
||||
var chart = this.chart, o = chart.options.mapNavigation, buttonOptions, attr, states, hoverStates, selectStates, outerHandler = function (e) {
|
||||
this.handler.call(chart, e);
|
||||
stopEvent(e); // Stop default click event (#4444)
|
||||
}, mapNavButtons = chart.mapNavButtons;
|
||||
// Merge in new options in case of update, and register back to chart
|
||||
// options.
|
||||
if (options) {
|
||||
o = chart.options.mapNavigation =
|
||||
merge(chart.options.mapNavigation, options);
|
||||
}
|
||||
// Destroy buttons in case of dynamic update
|
||||
while (mapNavButtons.length) {
|
||||
mapNavButtons.pop().destroy();
|
||||
}
|
||||
if (pick(o.enableButtons, o.enabled) && !chart.renderer.forExport) {
|
||||
objectEach(o.buttons, function (button, n) {
|
||||
buttonOptions = merge(o.buttonOptions, button);
|
||||
// Presentational
|
||||
if (!chart.styledMode) {
|
||||
attr = buttonOptions.theme;
|
||||
attr.style = merge(buttonOptions.theme.style, buttonOptions.style // #3203
|
||||
);
|
||||
states = attr.states;
|
||||
hoverStates = states && states.hover;
|
||||
selectStates = states && states.select;
|
||||
}
|
||||
button = chart.renderer
|
||||
.button(buttonOptions.text, 0, 0, outerHandler, attr, hoverStates, selectStates, 0, n === 'zoomIn' ? 'topbutton' : 'bottombutton')
|
||||
.addClass('highcharts-map-navigation highcharts-' + {
|
||||
zoomIn: 'zoom-in',
|
||||
zoomOut: 'zoom-out'
|
||||
}[n])
|
||||
.attr({
|
||||
width: buttonOptions.width,
|
||||
height: buttonOptions.height,
|
||||
title: chart.options.lang[n],
|
||||
padding: buttonOptions.padding,
|
||||
zIndex: 5
|
||||
})
|
||||
.add();
|
||||
button.handler = buttonOptions.onclick;
|
||||
// Stop double click event (#4444)
|
||||
addEvent(button.element, 'dblclick', stopEvent);
|
||||
mapNavButtons.push(button);
|
||||
// Align it after the plotBox is known (#12776)
|
||||
var bo = buttonOptions;
|
||||
var un = addEvent(chart, 'load', function () {
|
||||
button.align(extend(bo, {
|
||||
width: button.width,
|
||||
height: 2 * button.height
|
||||
}), null, bo.alignTo);
|
||||
un();
|
||||
});
|
||||
});
|
||||
}
|
||||
this.updateEvents(o);
|
||||
};
|
||||
/**
|
||||
* Update events, called internally from the update function. Add new event
|
||||
* handlers, or unbinds events if disabled.
|
||||
*
|
||||
* @function MapNavigation#updateEvents
|
||||
*
|
||||
* @param {Highcharts.MapNavigationOptions} options
|
||||
* Options for map navigation.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
MapNavigation.prototype.updateEvents = function (options) {
|
||||
var chart = this.chart;
|
||||
// Add the double click event
|
||||
if (pick(options.enableDoubleClickZoom, options.enabled) ||
|
||||
options.enableDoubleClickZoomTo) {
|
||||
this.unbindDblClick = this.unbindDblClick || addEvent(chart.container, 'dblclick', function (e) {
|
||||
chart.pointer.onContainerDblClick(e);
|
||||
});
|
||||
}
|
||||
else if (this.unbindDblClick) {
|
||||
// Unbind and set unbinder to undefined
|
||||
this.unbindDblClick = this.unbindDblClick();
|
||||
}
|
||||
// Add the mousewheel event
|
||||
if (pick(options.enableMouseWheelZoom, options.enabled)) {
|
||||
this.unbindMouseWheel = this.unbindMouseWheel || addEvent(chart.container, typeof doc.onmousewheel === 'undefined' ?
|
||||
'DOMMouseScroll' : 'mousewheel', function (e) {
|
||||
chart.pointer.onContainerMouseWheel(e);
|
||||
// Issue #5011, returning false from non-jQuery event does
|
||||
// not prevent default
|
||||
stopEvent(e);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
else if (this.unbindMouseWheel) {
|
||||
// Unbind and set unbinder to undefined
|
||||
this.unbindMouseWheel = this.unbindMouseWheel();
|
||||
}
|
||||
};
|
||||
// Add events to the Chart object itself
|
||||
extend(Chart.prototype, /** @lends Chart.prototype */ {
|
||||
/**
|
||||
* Fit an inner box to an outer. If the inner box overflows left or right,
|
||||
* align it to the sides of the outer. If it overflows both sides, fit it
|
||||
* within the outer. This is a pattern that occurs more places in
|
||||
* Highcharts, perhaps it should be elevated to a common utility function.
|
||||
*
|
||||
* @ignore
|
||||
* @function Highcharts.Chart#fitToBox
|
||||
*
|
||||
* @param {Highcharts.BBoxObject} inner
|
||||
*
|
||||
* @param {Highcharts.BBoxObject} outer
|
||||
*
|
||||
* @return {Highcharts.BBoxObject}
|
||||
* The inner box
|
||||
*/
|
||||
fitToBox: function (inner, outer) {
|
||||
[['x', 'width'], ['y', 'height']].forEach(function (dim) {
|
||||
var pos = dim[0], size = dim[1];
|
||||
if (inner[pos] + inner[size] >
|
||||
outer[pos] + outer[size]) { // right
|
||||
// the general size is greater, fit fully to outer
|
||||
if (inner[size] > outer[size]) {
|
||||
inner[size] = outer[size];
|
||||
inner[pos] = outer[pos];
|
||||
}
|
||||
else { // align right
|
||||
inner[pos] = outer[pos] +
|
||||
outer[size] - inner[size];
|
||||
}
|
||||
}
|
||||
if (inner[size] > outer[size]) {
|
||||
inner[size] = outer[size];
|
||||
}
|
||||
if (inner[pos] < outer[pos]) {
|
||||
inner[pos] = outer[pos];
|
||||
}
|
||||
});
|
||||
return inner;
|
||||
},
|
||||
/**
|
||||
* Highmaps only. Zoom in or out of the map. See also {@link Point#zoomTo}.
|
||||
* See {@link Chart#fromLatLonToPoint} for how to get the `centerX` and
|
||||
* `centerY` parameters for a geographic location.
|
||||
*
|
||||
* @function Highcharts.Chart#mapZoom
|
||||
*
|
||||
* @param {number} [howMuch]
|
||||
* How much to zoom the map. Values less than 1 zooms in. 0.5 zooms
|
||||
* in to half the current view. 2 zooms to twice the current view. If
|
||||
* omitted, the zoom is reset.
|
||||
*
|
||||
* @param {number} [centerX]
|
||||
* The X axis position to center around if available space.
|
||||
*
|
||||
* @param {number} [centerY]
|
||||
* The Y axis position to center around if available space.
|
||||
*
|
||||
* @param {number} [mouseX]
|
||||
* Fix the zoom to this position if possible. This is used for
|
||||
* example in mousewheel events, where the area under the mouse
|
||||
* should be fixed as we zoom in.
|
||||
*
|
||||
* @param {number} [mouseY]
|
||||
* Fix the zoom to this position if possible.
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
mapZoom: function (howMuch, centerXArg, centerYArg, mouseX, mouseY) {
|
||||
var chart = this, xAxis = chart.xAxis[0], xRange = xAxis.max - xAxis.min, centerX = pick(centerXArg, xAxis.min + xRange / 2), newXRange = xRange * howMuch, yAxis = chart.yAxis[0], yRange = yAxis.max - yAxis.min, centerY = pick(centerYArg, yAxis.min + yRange / 2), newYRange = yRange * howMuch, fixToX = mouseX ? ((mouseX - xAxis.pos) / xAxis.len) : 0.5, fixToY = mouseY ? ((mouseY - yAxis.pos) / yAxis.len) : 0.5, newXMin = centerX - newXRange * fixToX, newYMin = centerY - newYRange * fixToY, newExt = chart.fitToBox({
|
||||
x: newXMin,
|
||||
y: newYMin,
|
||||
width: newXRange,
|
||||
height: newYRange
|
||||
}, {
|
||||
x: xAxis.dataMin,
|
||||
y: yAxis.dataMin,
|
||||
width: xAxis.dataMax - xAxis.dataMin,
|
||||
height: yAxis.dataMax - yAxis.dataMin
|
||||
}), zoomOut = (newExt.x <= xAxis.dataMin &&
|
||||
newExt.width >=
|
||||
xAxis.dataMax - xAxis.dataMin &&
|
||||
newExt.y <= yAxis.dataMin &&
|
||||
newExt.height >= yAxis.dataMax - yAxis.dataMin);
|
||||
// When mousewheel zooming, fix the point under the mouse
|
||||
if (mouseX && xAxis.mapAxis) {
|
||||
xAxis.mapAxis.fixTo = [mouseX - xAxis.pos, centerXArg];
|
||||
}
|
||||
if (mouseY && yAxis.mapAxis) {
|
||||
yAxis.mapAxis.fixTo = [mouseY - yAxis.pos, centerYArg];
|
||||
}
|
||||
// Zoom
|
||||
if (typeof howMuch !== 'undefined' && !zoomOut) {
|
||||
xAxis.setExtremes(newExt.x, newExt.x + newExt.width, false);
|
||||
yAxis.setExtremes(newExt.y, newExt.y + newExt.height, false);
|
||||
// Reset zoom
|
||||
}
|
||||
else {
|
||||
xAxis.setExtremes(void 0, void 0, false);
|
||||
yAxis.setExtremes(void 0, void 0, false);
|
||||
}
|
||||
// Prevent zooming until this one is finished animating
|
||||
/*
|
||||
chart.holdMapZoom = true;
|
||||
setTimeout(function () {
|
||||
chart.holdMapZoom = false;
|
||||
}, 200);
|
||||
*/
|
||||
/*
|
||||
delay = animation ? animation.duration || 500 : 0;
|
||||
if (delay) {
|
||||
chart.isMapZooming = true;
|
||||
setTimeout(function () {
|
||||
chart.isMapZooming = false;
|
||||
if (chart.mapZoomQueue) {
|
||||
chart.mapZoom.apply(chart, chart.mapZoomQueue);
|
||||
}
|
||||
chart.mapZoomQueue = null;
|
||||
}, delay);
|
||||
}
|
||||
*/
|
||||
chart.redraw();
|
||||
}
|
||||
});
|
||||
// Extend the Chart.render method to add zooming and panning
|
||||
addEvent(Chart, 'beforeRender', function () {
|
||||
// Render the plus and minus buttons. Doing this before the shapes makes
|
||||
// getBBox much quicker, at least in Chrome.
|
||||
this.mapNavigation = new MapNavigation(this);
|
||||
this.mapNavigation.update();
|
||||
});
|
||||
H.MapNavigation = MapNavigation;
|
||||
@@ -0,0 +1,60 @@
|
||||
/* *
|
||||
*
|
||||
* (c) 2010-2020 Torstein Honsi
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*
|
||||
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
|
||||
*
|
||||
* */
|
||||
'use strict';
|
||||
import Pointer from '../Core/Pointer.js';
|
||||
import U from '../Core/Utilities.js';
|
||||
var extend = U.extend, pick = U.pick, wrap = U.wrap;
|
||||
/* eslint-disable no-invalid-this */
|
||||
// Extend the Pointer
|
||||
extend(Pointer.prototype, {
|
||||
// The event handler for the doubleclick event
|
||||
onContainerDblClick: function (e) {
|
||||
var chart = this.chart;
|
||||
e = this.normalize(e);
|
||||
if (chart.options.mapNavigation.enableDoubleClickZoomTo) {
|
||||
if (chart.pointer.inClass(e.target, 'highcharts-tracker') &&
|
||||
chart.hoverPoint) {
|
||||
chart.hoverPoint.zoomTo();
|
||||
}
|
||||
}
|
||||
else if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
|
||||
chart.mapZoom(0.5, chart.xAxis[0].toValue(e.chartX), chart.yAxis[0].toValue(e.chartY), e.chartX, e.chartY);
|
||||
}
|
||||
},
|
||||
// The event handler for the mouse scroll event
|
||||
onContainerMouseWheel: function (e) {
|
||||
var chart = this.chart, delta;
|
||||
e = this.normalize(e);
|
||||
// Firefox uses e.detail, WebKit and IE uses wheelDelta
|
||||
delta = e.detail || -(e.wheelDelta / 120);
|
||||
if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
|
||||
chart.mapZoom(Math.pow(chart.options.mapNavigation.mouseWheelSensitivity, delta), chart.xAxis[0].toValue(e.chartX), chart.yAxis[0].toValue(e.chartY), e.chartX, e.chartY);
|
||||
}
|
||||
}
|
||||
});
|
||||
// The pinchType is inferred from mapNavigation options.
|
||||
wrap(Pointer.prototype, 'zoomOption', function (proceed) {
|
||||
var mapNavigation = this.chart.options.mapNavigation;
|
||||
// Pinch status
|
||||
if (pick(mapNavigation.enableTouchZoom, mapNavigation.enabled)) {
|
||||
this.chart.options.chart.pinchType = 'xy';
|
||||
}
|
||||
proceed.apply(this, [].slice.call(arguments, 1));
|
||||
});
|
||||
// Extend the pinchTranslate method to preserve fixed ratio when zooming
|
||||
wrap(Pointer.prototype, 'pinchTranslate', function (proceed, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
|
||||
var xBigger;
|
||||
proceed.call(this, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
|
||||
// Keep ratio
|
||||
if (this.chart.options.chart.type === 'map' && this.hasZoom) {
|
||||
xBigger = transform.scaleX > transform.scaleY;
|
||||
this.pinchTranslateDirection(!xBigger, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, xBigger ? transform.scaleX : transform.scaleY);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user